mikerzz has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks, I am a perl newbie, for better or worse, converting old DOS and Unix shell scripts to Perl is now one of my responsibilities. That said, one of the scripts I am converting is being used to ftp files from server to server. I have been told that the ftp command MUST use the follwing command line arguments: ftp -v -i -n -s I have the Net::FTP module installed and was able to make the ftp work inside the script, but I can't figure out how to add those command line options to the: $ftp -> login("username", "password") Any suggestions would be greatly appreciated. Thanks Monks!

Replies are listed 'Best First'.
Re: Arguments with FTP command
by Joost (Canon) on Aug 13, 2008 at 17:33 UTC
    those arguments are parameters for some ftp command line program (my system's ftp program doesn't support -s). Net::FTP doesn't use that program so you'd want to look up the documentation for your ftp program and translate to your usage of Net::FTP. You can probably ignore most of those options, since they seem to be mostly intended to put ftp into "non-interactive/scriptable" mode, while Net::FTP was designed to be used from a script from the start. Or possibly shell out to your ftp program instead of using Net::FTP.

Re: Arguments with FTP command
by apl (Monsignor) on Aug 13, 2008 at 17:50 UTC
    • -v Shows all responses from the remote server

      You won't get the responses, only whether the action was successful or not.

    • -i Turns off interactive prompting

      By definition, you won't get prompted

    • -n Does not attempt "auto-login" upon initial connection.

      If you specify the ID and Password, auto-login won't take place by definition.

Re: Arguments with FTP command
by mr_mischief (Monsignor) on Aug 13, 2008 at 17:55 UTC
    The only version of ftp I find after a quick search of the environments on my two main desktops to have an -s option is the one supplied by Microsoft for command-line use within Windows. It's merely used to supply the name of a text file with FTP commands in it, which could be handled any number of other ways when you're writing the application.

    My suggestion would be to parse the text files that exist and perform the actions using Net::FTP. Barring that, I'd do as Joost suggests and wrap the existing FTP client.

    Be careful with other people's descriptions of the command-line options. For example, apl gives you the proper meaning of the -v option for the BSD and Linux version of ftp, but Microsoft uses the same option to mean the exact opposite.

      Thanks; I should have been explicit that I was referring to Solaris Unix (which, to the best of my knowledge, doesn't have a -v option).
Re: Arguments with FTP command
by mikerzz (Acolyte) on Aug 13, 2008 at 19:00 UTC
    Thanks for all of the replies, folks. I appreciate them. I will most likely end up shelling out to the current ftp client, so I can invoke those command line arguments.
      Given what apl and mr_mischief have said, I don't see the point of shelling out. The parameters are irrelevant in a situation where you are accessing another server using Net::FTP. Any configuration file you need could be read by perl itself (e.g. Config::Simple or Config::Tiny).