2011-04-10 79 views
0

Bellow是我的shell腳本代碼。我無法在終端上運行它。誰能告訴我這是爲什麼?在linux上創建ATM機系統的bash腳本

#!/bin/bash 
TIMELIMIT=500 

#start="y" 
while [["$start"!="n"]] 
do 
setterm-clear all 
echo -en'\E[45;55m'"\033[1mcopyright reserved by Ali\033[Om" 
echo " *********************************************************** " 
#tput sgr0 
#echo-e"\033[;10;40m" 
echo "PLEASE INSERT YOUR CARD" 
#tput sgr0 
#echo-e"\033[45;41m" 
echo "WELCOME TO BANK IT AUTOMATED TELLER MACHINE" 
sleep 5 
echo " Loading..." 
    #sleep 3 
#id=id | awk -F[=(]' '{print $1 $1 $1 $1}' 
#echo -e "\033[;10;40m" 
echo-e "PLEASE KEY IN YOUR PASSWOED: \c" 
#tput sgr0 
read-t $TIMELIMIT userpassword 
setterm-clear all 
if [-z"$userpassowrd" ] 
then 
echo "YOU USE TOO LONG TIME, PLEASE TRY AGAIN" 
sleep 3 
./t3.sh 
fi 

#seeterm-clear all 
echo "Loading..." 
sleep 5 
#setterm-clear all 
sleep 3 
idpassword="$userpassword" 
grep-s "$idpassword" db 
#Verify ID number with Password 

if ["$?" = 1] 
then 
echo "INVALIDE PASSWORD! PLEASE TRY AGAIN." 
sleep 3 
./t3.sh 
fi 

setterm-clear all 
nawk-F:'/'$idpassword'/{print $2}' db > db10 
username= 'cat db10' 

continue="y" 
while [["$continue"!= "n"]] 
do 
echo "WELCOME TO USE BANK IT ATM, $username" 
echo "Press 1 for Withdraw Money" 
echo "Press 2 for Balance Checking" 
echo "Press 3 for Logout" 
echo "Please Press Your Service:" 
#User no need press enter here. 
read-s-t $TIMELIMIT-n1 service 

if[-z"$service"] 
done 
echo Times out, please choose. 
sleep 3 
./t3.sh 
done 

setterm -clear all 
case "$service" in 
1) 
#cat db2 
#nawk -F:'/'*'/'$idpassword{print "lala"}' db 
#nawk 'sub(/'$idpassword'/,"asas"){print}' db >> db2 
awk '$1 !~/'$userpassword'/' db > db2 
echo "Withdraw Money" 
echo-e "Amount: RM\c" 
read withdrawAmount # echo . > db4 
nawk -F:'/'$idpassword'/{print $3}' db > db5 
oldbalance = 'cat db5'; 
newbalance = 'echo $oldbalance - $withdrawAmount | bc-1' 
newrecord = "$idpassword: $username: $newbalance" 
echo $newrecord > db3 
cat db3 >> db2 
cp db2 db 

#start inbound switch 
echo "continue?y n" 
read-s-n1 selection 
case"$selection"in 
;; 
y) 
setterm-clear all 
continue="y" #dont put space, for example, goout="n" 
;; 
n) 
setterm-clear all 
echo Thank you 
continue="n" 
sleep 4 
;; 
esac 
#end inbound switch 

2) 
nawk -F:'/'$idpassword'/{print " YOUR BALANCE IS: RM"$3}'db 

#start inbound switch 
echo "continue? y n" 
#read-s-n1 selection 
#case"$selection" in 
y) 
setterm-clear all 
continue="y" #dont put space, for example, goout="n" 
;; 
n) 
setterm-clear all 
echo Thank you 
continue="n" 
sleep 4 
;; 
esac 
#end inbound switch 
;; 

3) 
setterm -clear all echo "THANK YOU FOR USING OUR SERVICE" 
echo " *********************************************************** " 
break 
continue="n" 
sleep 3 
;; 
esac 
done 
done 
exit 0 


#exit 0 
#sleep 3000 
;; 
done 
+0

你需要更加清楚實際問題是什麼。 「不能在終端上運行」並不能真正發揮作用。 – Mat 2011-04-10 17:02:44

回答

2

像馬特說的,你需要更具體。然而,我注意到,這條線:

while [["$start"!="n"]] 

應該

while [[ "$start"!="n" ]] 

這意味着你需要後[[和]之前]空間。腳本中可能會有更多的錯誤,請進行調試,如果您有更具體的問題,只需詢問,社區可以提供幫助。

相關問題