[問題] shellscript執行指令 command not found
目前是想寫一個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
麻煩各位幫忙一下 卡了我好久
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.129.100.128
※ 文章網址: https://www.ptt.cc/bbs/LinuxDev/M.1424494245.A.6F4.html
※ 編輯: stellvia7 (220.129.100.128), 02/21/2015 12:52:39
※ 編輯: stellvia7 (220.129.100.128), 02/21/2015 12:53:01
推
02/22 11:22, , 1F
02/22 11:22, 1F
推
02/22 11:24, , 2F
02/22 11:24, 2F
→
02/22 11:25, , 3F
02/22 11:25, 3F
→
02/22 11:25, , 4F
02/22 11:25, 4F
→
02/23 03:25, , 5F
02/23 03:25, 5F
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章