Bash error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash error
# 1  
Old 11-21-2010
Bash error

Code:
#!/bin/bash


echo "Select:"
echo "1.chat.txt"
echo "2.movie.txt"

read num
case $num in 
    1)editchat()
    ;;
    2)editmovie()
    ;;
esac

function editchat()
{
    DR=/media/sda2/works/textfiles
    echo "Openning ${DR}/chat.txt with gvim"
    cd ${DR}
    gvim c.txt&
    echo "Done"
}

function editmovie()
{
    DR=/media/sda2/works/textfiles
    echo "Openning ${DR}/chat.txt with gvim"
    cd ${DR}
    gvim m.txt&
    echo "Done"
}

Code:
./edit.sh: line 11: syntax error near unexpected token `;;'
./edit.sh: line 11: `    ;;'

Why?

---------- Post updated at 04:01 PM ---------- Previous update was at 03:54 PM ----------

Fixed.
Code:
#!/bin/bash

function editchat()
{
    DR=/media/sda2/works/textfiles
    echo "Openning ${DR}/chat.txt with gvim"
    cd ${DR}
    gvim chat.txt&
    echo "Done"
}

function editmovie()
{
    DR=/media/sda2/works/textfiles
    echo "Openning ${DR}/chat.txt with gvim"
    cd ${DR}
    gvim movie.txt&
    echo "Done"
}
echo "Select:"
echo "1.chat.txt"
echo "2.movie.txt"

read num
case $num in 
    1)editchat
    ;;
    2)editmovie
    ;;
esac

# 2  
Old 11-21-2010
Not sure it come from this but here are 2 points you can test :
a) call the function withouthe the ()
b) function must be dclared before being called

---------

Ooops cola answered while i was editing my post Smilie
just refer to his code as i suggested
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Error when running bash

Hi, I installed bash into one HPUX Itanium server. The dependencies I installed together with it were libiconv, termcap and gettext. Installation was successful for all depot files. However, when I run "bash" on the prompt, I get this error : # bash /usr/lib/hpux32/dld.so: Unable to... (1 Reply)
Discussion started by: anaigini45
1 Replies

2. BSD

Keep getting error "-bash: ./.profile_z2: line 52: syntax error: unexpected end of file"

#!/bin/bash #-------------------------------------------------------- # Setup prompt # Author Zeeshan Mirza # Data: 06-08-2017 #-------------------------------------------------------- if then . ./.profile_custom_pre fi umask 022 set -o vi export EDITOR=vi export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies

3. Shell Programming and Scripting

Bash syntax error

while read line do mkdir $line scp -r Docking_results/docking_$line.pdb $line/ cd /$line/ set a=`grep ENDMDL docking_'$line'.pdb | wc -l` set b=`expr $a - 2` csplit -k -s -n 3 -f docking_'$line'. docking'$line'.pdb '/^ENDMDL/+1' '{'$b'}' foreach f (... (4 Replies)
Discussion started by: chrisjorg
4 Replies

4. Solaris

Bash display error

Some of my admin made some changes on my Solaris-10 box and after that I started getting this wiered issue. I checked path, but not able to figure it out. This is for a non-root user gcadmin@brbpod06: $ echo $SHELL /usr/bin/bash gcadmin@brbpod06: $ bash bash: brbpod06:: command not found... (2 Replies)
Discussion started by: solaris_1977
2 Replies

5. Shell Programming and Scripting

if test in bash - can't see error

Hi, I have the following script under bash if ; then echo File $file_name Not Found else echo File $file_name Found fi I get the message even the file is found; there is only one file with that name in the directory I can't figure... (4 Replies)
Discussion started by: f_o_555
4 Replies

6. UNIX for Dummies Questions & Answers

fix the if and then error in bash

For anyone have work in bash shell scripting before know the if and then statement it work like this if (condition); then I have create a mini shell in C, and I want to make it a bit more tolerable than the normal bash shell where you do not need the ';' between if and then if they are in the... (2 Replies)
Discussion started by: snow2462
2 Replies

7. UNIX for Dummies Questions & Answers

useradd on bash gives me error

Hi everyone, On executing the following command i always get this error >useradd -c 'none' -s # -u 5001 -f 100 -m -g 'wheel' -d /home/phildpop useradd: option requires an argument -- s Try `useradd --help' or `useradd --usage' for more information. (1 Reply)
Discussion started by: phildpop
1 Replies

8. Shell Programming and Scripting

Help in error seen in the Bash script

Hi, I am currently encounter an error of:- ./max.bash: line 45: then max=0 else max=$maximum It seems that it does not allow max to assigned with floating numbers. Please help. Thanks. (2 Replies)
Discussion started by: ahjiefreak
2 Replies

9. Shell Programming and Scripting

Bash Script error?

I'm currently playing with the below script; #!/bin/sh for d in /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \ /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \ /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \ ... (13 Replies)
Discussion started by: JayC89
13 Replies

10. UNIX for Dummies Questions & Answers

Bash installation error

Hi I'm using svr4 and trying to install bash 3.0.16. it configures fine but once I type make I get the following error making ./lib/intl/libintl.a in ./lib/intl make: fatal error: don't know how to make ./gettextP.h (bu42). *** Error code 1 (bu21) make: fatal error. Any ideas? ... (0 Replies)
Discussion started by: c19h28O2
0 Replies
Login or Register to Ask a Question