![ssh 将 Unix pwd 命令的输出重定向到本地服务器的文件](https://linux22.com/image/119805/ssh%20%E5%B0%86%20Unix%20pwd%20%E5%91%BD%E4%BB%A4%E7%9A%84%E8%BE%93%E5%87%BA%E9%87%8D%E5%AE%9A%E5%90%91%E5%88%B0%E6%9C%AC%E5%9C%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E6%96%87%E4%BB%B6.png)
脚本abcd.sh:
####
ssh $user_name@$ftp_site pwd > /export/home/appwxsms/remotepathfile.lst;
pathofremote =`sed -n '1p' $HOME/remotepathfile.lst`
export pathofremote
#####
运行abcd.sh:
-bash:./abcd.sh
pathofremote: command not found
remotepathfile.lst > output.txt
-bash: /export/home/appwxsms/remotepathfile1.lst: Permission denied
运行 abcd.sh 脚本时,我无法将本地路径 remotepathfile.lst 中生成的文件的输出发送到变量pathofremote
另外,我无法将文件的输出保存到本地服务器中的另一个文件。
答案1
尽管变量分配中存在语法错误,该文件仍将按照您希望的方式填充。
foo =bar # This will attempt to run the command 'foo' with the parameter '=bar'
foo=bar # This will set the variable 'foo' equal to 'bar'
foo="$(bar)" # This will set the variable 'foo' to the output of the execution of 'bar'