我正在尝试自动从一台服务器到另一台服务器进行文件传输或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 [email protected] <<_EOF_
cd /upload/
put $FILE
_EOF_
# Exit
exit $?
当我执行此shell脚本时,在腻子中收到以下错误:
-bash: sshpass: command not found
我尝试通过ssh-keygen -t dsa
其他步骤使用ssh无密码方法,但由于无法执行后续步骤,因此无法访问第二台服务器的腻子。
请帮助
您将需要在正在运行代码的客户端服务器上安装sshpass,该代码是大多数Linux发行版中默认未安装的工具
如果您在Ubuntu中,请使用此命令
apt-get install sshpass
在centOS / redhat上使用此安装epel
wget https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
安装sshpass
yum --enablerepo = epel -y安装sshpass
谢谢
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句