linux – 命令在脚本中不起作用,但在shell中起作用

linux – 命令在脚本中不起作用,但在shell中起作用,第1张

概述我正在编写一个使用SSH“配置文件”的脚本,〜/ scripts / ssh-profiled.sh PROFILE=`cat ~/script/ssh-profiles/$1`echo [ssh $PROFILE]ssh $PROFILE 〜/脚本/ SSH型材/ tummi -i ~/Dropbox/security/key-nopass/key-nopass.pvt bart@examp 我正在编写一个使用SSH“配置文件”的脚本,〜/ scripts / ssh-profiled.sh

PROfile=`cat ~/script/ssh-profiles/`echo [ssh $PROfile]ssh $PROfile

〜/脚本/ SSH型材/ tummi

-i ~/DropBox/security/key-nopass/key-nopass.pvt [email protected]

当我运行脚本时,它失败了:

bart@bart-laptop:~$script/ssh-profiled.sh tummi[ssh -i ~/DropBox/security/key-nopass/key-nopass.pvt [email protected]]Warning: IDentity file ~/DropBox/security/key-nopass/key-nopass.pvt not accessible: No such file or [email protected]'s password:

但这有效:

bart@bart-laptop:~$ssh -i ~/DropBox/security/key-nopass/key-nopass.pvt [email protected] tummi 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/linuxUbuntu 10.04.1 LTSWelcome to the Ubuntu Server!

我的脚本中是否有错误/陷阱?

解决方法 将第1行更改为

eval PROfile=`cat ~/script/ssh-profiles/`

有关解释,请参阅here

总结

以上是内存溢出为你收集整理的linux – 命令在脚本中不起作用,但在shell中起作用全部内容,希望文章能够帮你解决linux – 命令在脚本中不起作用,但在shell中起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1023773.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存