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/b in
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/b in/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/b in
if i run the three line command in the shell manually it works fine
cd /usr/local/openjms-0.7.5/b
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/b
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/b
if i run the three line command in the shell manually it works fine
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
check with 'which tcsh' where you shell is and then add as 1st line of script
#!/actual/path/to/tcsh
probably
#!/bin/tcsh
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?
ASKER
@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/b in
#source ./setenv.sh
#nohup ./openjms.sh &> /dev/null &!
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/b
#source ./setenv.sh
#nohup ./openjms.sh &> /dev/null &!
ASKER
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.
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.
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 &!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
#!/usr/bin/csh (or the path to csh on your system)