我正在尝试自动化从一台服务器到另一台服务器的文件传输或 FTP。
#!/bin/bash
### In this model, the same filename is processed on each run.
### A timestamp is added to the result file and data file is copied to the archive or error folder with a timestamp after processing.
# Set current directory
cd `dirname "$0"`
# Set the environment variables
. ./Environment.sh $0
#######################################################################################################
#
#######################################################################################################
FILE=/hcm/Inbound/file.csv
sshpass -p 'xyz' sftp -oBatchMode=no -b - -oStrictHostKeyChecking=no zys@192.abc.taleo.net <<_EOF_
cd /upload/
put $FILE
_EOF_
# Exit
exit $?
当我执行这个 shell 脚本时,我在 putty 中收到以下错误:
-bash: sshpass: command not found
我尝试通过 ssh-keygen -t dsa
和其他步骤使用 ssh 无密码方法,但我无法访问第二台服务器的腻子,因此无法执行后续步骤。
请帮助
原文由 sreekem bose 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要在运行代码的客户端服务器上安装 sshpass,该工具是大多数 Linux 发行版默认未安装的工具
如果你在 Ubuntu 中使用这个命令
在 centOS/redhat 上使用这个 install epel
安装 sshpass
谢谢