[问题] shellscript执行指令 command not found

楼主: stellvia7 (stellvia)   2015-02-21 12:50:43
目前是想写一个script 读取档案a
此档案a有写要执行的指令以及要下的参数,且每个参数会用"," 隔开
但是会出现command not found
目前卡在有空白的指令就会 command not found
a:
#arg0 execute or not
#arg1 command
#arg2 match pattern
#arg3 timeout
1,ls,test,2
1,ls -al,test,2
作者: goldie (阿良)   2015-02-22 11:22:00
加个eval吧: log="$(eval "$2")"此外,bash可以把exec < 跟while do ... done合并成:done < $filename然后exec < $filename那行就可以拿掉了
楼主: stellvia7 (stellvia)   2015-02-23 03:25:00
太感谢您了 解了 谢谢x9999

Links booklink

Contact Us: admin [ a t ] ucptt.com