Link to home
Create AccountLog in
Avatar of angelblade27
angelblade27

asked on

invalid token for shell script

I have a shell script as follows  (name of the shell script is restartOpenJMS.sh):

cd /usr/local/openjms-0.7.5/bin
source ./setenv.sh
nohup ./openjms.sh start &> /dev/null &!

however when i run the script i get the follow problems

./restartOpenJMS.sh: line 4: syntax error near unexpected token `newline'
./restartOpenJMS.sh: line 4: `nohup /usr/local/openjms-0.7.5/bin/openjms.sh &> /dev/null &!'
 also when just having the first line in the shell script when i execute it and then do
pwd
i notice i'm still in my home directory and not in
 /usr/local/openjms-0.7.5/bin

if i run the three line command in the shell manually it works fine
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

this is a csh script. Do you have csh on your system? Please include

#!/usr/bin/csh (or the path to csh on your system)
Avatar of proglot
proglot

by default your system try to interpret this script as sh or bash script and you using csh or tcsh syntax
check with 'which tcsh' where you shell is and then add as 1st line of script
#!/actual/path/to/tcsh

probably

#!/bin/tcsh
Avatar of angelblade27

ASKER

not sure. when i checked the location you gave i don't  path. How would i be able to determine which on ei have and if i don't have it how can i instal this?
@proglot:
so i do have /bin/tcsh
i commented out the next couple of lines and ran it to see if it would change dir but it didn't the .sh script is
#!/bin/tcsh
cd /usr/local/openjms-0.7.5/bin
#source ./setenv.sh
#nohup ./openjms.sh &> /dev/null &!
Forgot what i asked earlier i realised that it opens a different shell
however when i run the script now i get
export: Command not found.
export: Command not found.
export: Command not found.
Invalid null command.
change dir happens in sub shell - inside script, so when it finishes you back in you original dir
if want see in which dir you are while script running, then use 'pwd' command
I think that ./setenv.sh is not a csh script, but bash script so need to remove source before it
check the first line of ./setenv.sh and post it here.
#!/bin/tcsh
cd /usr/local/openjms-0.7.5/bin
pwd
./setenv.sh
nohup ./openjms.sh &> /dev/null &!

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of robot3367
robot3367

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer