net-ftp icon indicating copy to clipboard operation
net-ftp copied to clipboard

Quote and Literal subcommands are implemented

Open mslinn opened this issue 9 months ago • 1 comments

Fixes #33

mslinn avatar May 02 '24 20:05 mslinn

The modifications in the pull request have been tested against an IBM z/OS Communications Server. The following code fragment uses FTP to submit a batch job to the mainframe, and collects the results.

def parse_job_number_from(line)
  tokens = line.split('JOB')
  raise StandardError, "Error: The string 'JOB' was not found in the FTP response." unless tokens.length == 2

  job_number = tokens[1].split.first
  job_number.sub(/^0+/, '') # Remove leading zeros
end
    
Net::FTP.open(@ip_or_domain) do |ftp|
  ftp.login @uid, @pwd
  ftp.quote 'site filetype=jes'
  job_info = ftp.puttextfile @local_jcl_filepath
  job_number = parse_job_number_from job_info
  ftp.gettextfile "J#{job_number}", @local_results_file
end

mslinn avatar May 03 '24 21:05 mslinn

It looks good. Thank you!

shugo avatar Jun 01 '24 07:06 shugo

The version of the net-ftp Ruby gem containing this PR was tagged as v0.3.6. Looks like v0.3.6 was not released and there were no change notes. There was no mention of this pull request in v0.3.7 either, although the code from this PR is there. Seems like the credit for my contribution fell through the cracks. Might it be possible to fix that somehow?

mslinn avatar Jun 28 '24 03:06 mslinn

@mslinn It seems that v0.3.6 release was left as draft. I've just published it: https://github.com/ruby/net-ftp/releases/tag/v0.3.6

shugo avatar Jun 28 '24 22:06 shugo

@shugo Many thanks!

mslinn avatar Jun 28 '24 23:06 mslinn

I noticed that the sample code I showed above from May 3 does not appear in the documentation. How might that be accomplished?

mslinn avatar Oct 09 '24 17:10 mslinn

I noticed that the sample code I showed above from May 3 does not appear in the documentation. How might that be accomplished?

What do you mean by the words "the sample code I showed above from May 3"? It seems that documentation returned by ri and gem server contains description in your patch, but I couldn't find "sample code" in your patch.

$ ri Net::FTP#quote
= Net::FTP#quote

(from gem net-ftp-0.3.8)
=== Implementation from FTP
------------------------------------------------------------------------
  quote(arguments)

------------------------------------------------------------------------

The "quote" subcommand sends arguments verbatim to the remote ftp
server. The "literal" subcommand is an alias for "quote". @param
arguments Array[String] to be sent verbatim to the remote ftp server

shugo avatar Oct 10 '24 06:10 shugo

Here is the documentation again:

The modifications in the pull request have been tested against an IBM z/OS Communications Server. The following code fragment uses FTP to submit a batch job to the mainframe, and collects the results.

def parse_job_number_from(line)
  tokens = line.split('JOB')
  raise StandardError, "Error: The string 'JOB' was not found in the FTP response." unless tokens.length == 2

  job_number = tokens[1].split.first
  job_number.sub(/^0+/, '') # Remove leading zeros
end
    
Net::FTP.open(@ip_or_domain) do |ftp|
  ftp.login @uid, @pwd
  ftp.quote 'site filetype=jes'
  job_info = ftp.puttextfile @local_jcl_filepath
  job_number = parse_job_number_from job_info
  ftp.gettextfile "J#{job_number}", @local_results_file
end

mslinn avatar Oct 10 '24 10:10 mslinn