#!/usr/dt/bin/dtksh
while getopts w:m: option
do
case $option in
w) wflag=1
wval="$OPTARG";;
m) mflag=1
mval="$OPTARG";;
?) printf 'BAD\n' $0
exit 2;;
esac
done
if [ ! -z "$wflag" ]; then
printf "W and -w arg is $wval\n"
fi
if [ ! -z "$mflag" ]; then
printf "M and -m arg is $mval\n"
fi
shift $(($OPTIND - 1))
printf "Remaining arguments are: $* \n"
at $wval <<ENDMARKER
echo $* >> Search_List
tr " " "\n" <Search_List >Usr_List
while true; do
if [ -s Usr_List ]; then
for i in $(cat Usr_List); do
if finger -m | grep $i; then
echo '$i is online' | elm user
sed '/$i/d' <Usr_List >tmplist
mv tmplist Usr_List
fi
done
else
break
fi
done
ENDMARKER
基本上我想繼續搜索直到它爲空。每次找到列表的一個元素時,它都會被刪除。一旦清單是空的退出。我在unix的at作業的輸出上總是收到一個'while syntax'錯誤,我不知道爲什麼
當我第一次運行命令時,沒有錯誤消息,它只顯示在包含at作業輸出的電子郵件中。
預先感謝任何建議
編輯:腳本使用getopts的,並採取了-w一個參數,一個用於-m,W值設置爲時間,以使工作的M仍然有要使用的。 m之後的任何參數都會發送到一個名爲Search_List的文件,Search_List被編輯並保存爲Usr_List。然後在while循環中,雖然Usr_List不爲空,但腳本會檢查finger -m的結果與Usr_List中的名稱。如果找到名稱,它將從Usr_List中刪除。一旦Usr_List爲空,程序應該停止。
elm是一種發送電子郵件的方式,因此elm用戶會向用戶發送電子郵件。
的錯誤是:
同時:表達式語法
shebang'/ usr/dt/bin/dtksh'是你期望的嗎?它是ksh嗎? – 2013-03-17 21:54:47
這對我已經完成的每一個其他腳本都有效,它是一個korn外殼 – user2177896 2013-03-17 22:02:15
更好地解釋你想用英文做什麼,什麼是'elm'。 – 2013-03-17 22:13:23