使用Mac OS X的Bash脚本中的SFTP命令 [英] SFTP command in Bash script with Mac OS X
问题描述
我需要使用Mac主机上的SFTP和SSH将文本文件传输到远程PC(freeSSH).这两个连接在本地网络中.
I need to transfer a text file to a remote PC (freeSSH) using SFTP and SSH from a Mac host. These two are connected in a local network.
有没有办法从Bash脚本中运行SFTP命令(提供用户名和密码)?
So is there a way to run an SFTP command (with the username and password provided) from inside the Bash script?
我已经用expect
尝试了一些脚本,但是没有得到任何结果.
I already tried some scripting with expect
, but I didn't get any results.
I found a similar post, How to run the sftp command with a password from a Bash script, but it is for Linux. I have a Mac.
推荐答案
您也可以在Mac上下载并安装sshpass.从此下载链接
You can download and install sshpass on Mac as well. Get the latest version source from this download link
我的链接答案中有使用sshpass的其余步骤.
Rest of the steps on using sshpass are there in the linked answer of mine.
这篇关于使用Mac OS X的Bash脚本中的SFTP命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!