我有一个在 Linux 上运行的 FTP 脚本,但它失败了。这是脚本:
/usr/bin/ftp -v -i -n my.ftp.server << cmd
user ftpuser password
binary
ls
<some other commands here>
quit cmd
它返回一个错误:
421 Service not available, remote server has closed connection
Not connected.
奇怪的是,如果我只是在命令行中输入: /usr/bin/ftp my.ftp.server 它要求输入用户名和密码,在我提供它们之后,我就能够连接了!
In ftp> 我输入 ls,我可以看到来自 FTP 服务器的文件。 我的脚本有什么问题?
而且,我没有 FTP 服务器的 putty 访问权限,所以我看不到那里的日志。有什么想法吗?
谢谢!
最佳答案
这里是一个正确的 ftp linux 脚本的例子。
#!/bin/sh
HOST='ftp.server.com'
USER='user'
PASSWD='pw'
FILE='file.txt' #sample file to upload
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE #sample command
#some other commands here
quit
END_SCRIPT
exit 0
关于linux - FTP 脚本不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26525327/