我创建了一个脚本来将本地文件复制到远程文件夹,该脚本在 if 条件之外工作正常,但是当我将 if 条件括起来时,put 命令不起作用并使用 sftp 协议登录到远程服务器,当存在时它显示错误:未找到放置命令
查看执行脚本后发生了什么
Connected to 10.42.255.209.
sftp> bye
sftp.sh: line 23: put: command not found
Run Code Online (Sandbox Code Playgroud)
请找到以下脚本。
echo -e;
echo -e "This script is used to copy the files";
sleep 2;
localpath=/home/localpath/sftp
remotepath=/home/destination/sftp/
if [ -d $localpath ]
then
echo -e "Source Path found"
echo -e "Reading source path"
echo -e "Uploading the files"
sleep 2;
sftp username@10.42.255.209
put $localpath/* $remotepath
else
Run Code Online (Sandbox Code Playgroud)