- 论坛徽章:
- 1
|
目前是想寫一個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
--------------------------------------
test.sh:
#!/bin/bash
IFS=","
filename='commands'
exec < $filename
while read line
do
set $line
if [ "$1" == "1" ]; then
echo "Now Execute command $2, compare with $3, set timeout $4"
log="$($2)" ==> 問題在這邊會出現command not found : ls -al
==> 假如指令只有 ls 就沒問題,多了一個空白就不行
....
....
done
麻煩各位幫忙一下 卡了我好久
謝謝 |
|