Perl 自动FTP会话

Perl 自动FTP会话,perl,bash,ftp,ksh,Perl,Bash,Ftp,Ksh,我从一个自动执行FTP会话的perl脚本中摘录了以下内容,希望有人能解释它是如何工作的 system("rsh some_server ftp -in ftp.something.com << ! user anonymous someone\@somewhere.org some ftp commands bye"); system(“rsh some_server ftp-in ftp.something.com你看过手册页了吗 -i Turns off interact

我从一个自动执行FTP会话的perl脚本中摘录了以下内容,希望有人能解释它是如何工作的

system("rsh some_server ftp -in ftp.something.com << !
user anonymous someone\@somewhere.org
some ftp commands
bye");

system(“rsh some_server ftp-in ftp.something.com你看过手册页了吗

-i    Turns off interactive prompting during multiple file transfers.

-n    Restrains ftp from attempting “auto-login” upon initial connection.  If auto-login is enabled, ftp will check the .netrc (see netrc(5)) file in the user's
       home directory for an entry describing an account on the remote machine.  If no entry exists, ftp will prompt for the remote machine login name (default is
       the user identity on the local machine), and, if necessary, prompt for a password and an account with which to login.


 The client host and an optional port number with which ftp is to communicate may be specified on the command line.  If this is done, ftp will immediately attempt
 to establish a connection to an FTP server on that host; otherwise, ftp will enter its command interpreter and await instructions from the user.  When ftp is
 awaiting commands from the user the prompt ‘ftp>’ is provided to the user.  The following commands are recognized by ftp:

 ! [command [args]]
             Invoke an interactive shell on the local machine.  If there are arguments, the first is taken to be a command to execute directly, with the rest of
             the arguments as its arguments.

所以本质上你是在ftp中输入,并在每行中提供一个新命令,而不是从文件中输入。

你是对的,
是的,我确实看了手册页,但我仍然不明白。什么是
它看起来脆弱且容易出错,我会坚持使用Net::ftp和Net::ssh2。我喜欢使用“herdoc”作为herdoc分隔符的想法。明白了吗同意这段代码是令人困惑的。显然,原作者也感到困惑。使用适当的perl模块会更好,但当然我正在使用现有代码,重写所有内容并不总是切实可行的。至少他们告诉我的是这样。
sh: line 2: warning: here-document at line 0 delimited by end-of-file (wanted `!')
<< HEREDOC
command < file
$ cat file
user anonymous someone\@somewhere.org
some ftp commands
bye
$ ftp -in ftp.something.com < file
system("rsh some_server ftp -in ftp.something.com << HEREDOC
user anonymous someone\@somewhere.org
some ftp commands
bye
HEREDOC");