将 sftp shell 脚本命令转换为 ftp 命令

发布于 2024-12-02 19:43:00 字数 366 浏览 3 评论 0原文

我正在编写我的第一个 shell 脚本,并试图找出如何将此命令:转换

sftp -o IdentityFile=/home/test/test/id_dsa [email protected] < sftp_put.txt; 

为连接到 ftp 服务器的等效命令。关键的区别是我将通过用户名和密码而不是我的 ssh 凭据登录到该服务器。注意我正在尝试上传两个文件。

再次感谢任何帮助!

I am writing my first shell script ever and trying to figure out how to transform this command:

sftp -o IdentityFile=/home/test/test/id_dsa [email protected] < sftp_put.txt; 

into an equivalent command where I connect to a ftp server. The key difference is that I will be logging into this server via a username and password not my ssh credentials. Note I am trying to upload two files.

Again any help would be more than appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回首观望 2024-12-09 19:43:00

您可以使用 .netrc 来实现此目的:

$ cat > .netrc
machine your.machine.ip.address
login your.login.name
^D
$ ftp your.machine.ip.address < ftp_cmds.txt

这会提示您输入密码。如果您同意,可以将密码(明文)保存在 .netrc 中以跳过此提示。有关更多详细信息,请参阅man netrc

You can use .netrc for this:

$ cat > .netrc
machine your.machine.ip.address
login your.login.name
^D
$ ftp your.machine.ip.address < ftp_cmds.txt

Which would prompt you for a password. If you're okay with it, you can save the password (clear text) in .netrc to skip this prompt. See man netrc for more details.

缘字诀 2024-12-09 19:43:00
   ftp -v -n <<EOF > ${LOG_FTP} 2>&1
   open ${IP_ADDRESS_SERVER}
   user ${FTPUSER} ${FTPPASS}
   cd ${REMOTE_DIR}
   put sftp_put.txt
EOF
   ftp -v -n <<EOF > ${LOG_FTP} 2>&1
   open ${IP_ADDRESS_SERVER}
   user ${FTPUSER} ${FTPPASS}
   cd ${REMOTE_DIR}
   put sftp_put.txt
EOF
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文