[SLE] opportunity to install SuSE at work, but...
bash scripts are not behaving. The following script, which works on my SuSE 6.3 at home, fails on SuSE 6.4 at work with the following messages: ...Line 4: syntax error near unexpected token clearscr(){ ...Line 4: 'clearscr(){ If I remove the function and put its contents in place of clearscr then I get the same error msg but it barfs on the 'in' of 'case $mychoice in'. Bash will also barf if it encounters a blank line, or any trailing white spaces. Sensitivities which SuSE at home never displays. I carefully removed all trailing white spaces from each line, made each space between words just 1 char wide, and removed all blank lines. I made sure all indentation was by tabs. It worked for a while, but the next time I edited the script, to remove a '-k' from the sz line, it barfed and has refused to work since. Here is the script: #!/bin/bash fext=".001" clearscr(){ clear; echo "Hello, $LOGNAME, Select your choice:"; echo "1) Change Password"; echo "2) Download file using a 3 digit Julian day. Today:$(date +%j)"; echo "3) Quit"; } clearscr while true do echo -n "Choice? " read mychoice case "$mychoice" in 1) echo "Passwords must be 8 or less characters and/or numbers" sleep 3 passwd $LOGNAME echo "$LOGNAME did a Password change" >> /tmp/bbs_users_log echo "Password command completed..." sleep 2 ;; 2) ls *.001 echo -n "Enter the 3 digit Julian Day, 001 to 365:" read julian fname="$LOGNAME$julian$fext" if [ -f $fname ] && [ -n $fname ] then sz -Z -N $fname echo "$LOGNAME Downloaded file:$fname">> /tmp/bbs_users_log echo "Download complete" sleep 1 else echo "Couldn't find: $fname , or file was empty." sleep 2 fi ;; 3) exit ;; *) echo "$mychoice is NOT a choice" sleep 2 esac clearscr done -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
jkreps@rev.state.ne.us wrote:
bash scripts are not behaving. The following script, which works on my SuSE 6.3 at home, fails on SuSE 6.4 at work with the following messages: ...Line 4: syntax error near unexpected token clearscr(){ ...Line 4: 'clearscr(){
I cut&paste it from your email to my SuSE Linux 7.0 and it runs fine. -- Michael Hasenstein http://www.suse.de/~mha/ SuSE Linux AG, Nuernberg (Germany) SuSE Inc., Oakland, California (US) -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
participants (2)
-
jkreps@rev.state.ne.us
-
mha@suse.com