LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   nothing happens when I execute a script (https://www.linuxquestions.org/questions/linux-newbie-8/nothing-happens-when-i-execute-a-script-4175500668/)

oraenthu@live.com 04-05-2014 07:43 AM

nothing happens when I execute a script
 
Linux 2.6.32-400.21.1.el5uek #1 SMP Wed Feb 20 01:35:01 PST 2013 x86_64 x86_64 x86_64 GNU/Linux

the script starts with a
#!/bin/sh
and then exports the PATH also
the permissions are 777
But nothing actually happens when I execute it using
sh scriptname.sh
I have written scripts earlier but am not able to figure out what I am missing

Please help
Thanks

grail 04-05-2014 07:52 AM

Please show the actual script as thus far it is impossible to tell if anything should actually happen?

Also, what do you expect to happen?

oraenthu@live.com 04-05-2014 08:36 AM

Code:

#!/bin/sh
#########      Oracle Environment Variables  ####################
ORACLE_BASE=/u01/app/oracle/product;
ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1;
ORACLE_SID=asdf
PATH=/usr/local/bin:/bin:/usr/bin:/u01/app/oracle/product/11.2.0.3/dbhome_1/bin
export ORACLE_SID ORACLE_BASE ORACLE_HOME
export PATH

#################################################################
PWD_DIR=$HOME/PWD_FILE
DIR=$HOME/cronscripts
PWD_FILE=$PWD_DIR/abc_system.sgn
SCRIPTS_DIR=$DIR/scripts
SCR_BASE=$HOME/cronscripts
SCR_LOC=$SCR_BASE/batchjobs
LOG_LOC=/$HOME/cronscripts/logs
LOG_FILE=$LOG_LOC/mno_mail.log
#################################################################
#
# password file check
#
#################################################################
if [ -f "$PWD_FILE" ]
then
        USER_PASSWD=` cat "$PWD_FILE" `
else
        echo "Password file '$PWD_FILE' is required." > $LOG_LOC/password_not_found_file.out
        echo $ORACLE_SID >> $LOG_LOC/password_not_found_file.out
        LOG_NAME=$LOG_LOC/password_not_found_file.out
        mail -s "Exporting abc.mno - Password not found!" "abc@xyz.com" > /dev/null <${LOG_NAME}
        exit
fi


echo ' **************************************************************************************************** ' >$LOG_FILE
echo ' **************************************************************************************************** ' >>$LOG_FILE
echo ' starting process... ' >> $LOG_FILE
echo ' Time : ' `date` >> $LOG_FILE
starttime=`date`
echo ' **************************************************************************************************** ' >>$LOG_FILE
echo "Executing ${0} ..." >> $LOG_FILE

$ORACLE_HOME/bin/sqlplus -s << EOF >> $LOG_FILE
$USER_PASSWD
@$SCRIPTS_DIR/mnopq.sql;

EOF
EXP_LOG=mno
DATE_VAR=`date +"%Y%m"`
EXP_LOG=$EXP_LOG{$DATE_VAR}
cat /u02/EXP_DUMP/{$EXP_LOG}.log >> $LOG_FILE
end_time=`date`

echo " " >> $LOG_FILE
echo "---------------" >> $LOG_FILE
echo "Start Time:" $start_time >> $LOG_FILE
echo "End  Time:" $end_time >> $LOG_FILE
echo "---------------" >> $LOG_FILE


grail 04-05-2014 09:16 AM

Ok ... so firstly, please use [code][/code] tags when displaying code or data.

You have provided your script ... cheers, but you did not answer my question ... what do you expect to see happen?

On a brief look at that script I cannot see that it will display anything to the screen unless an error happens.

So please advise what the problem is more specifically?

oraenthu@live.com 04-05-2014 09:26 AM

My apologies, thanks for being patient.
This exports a table (80 Gig) and this takes time
when I execute the script using sh scriptname.sh I cannot see the script as a process when I do a ps -ef|grep scriptname
when I try to run it using nohup sh scriptname.sh & the screen immediately outputs
Code:

"Done                      scriptname.sh"
This is all that I can explain as this is all I see.

sgosnell 04-05-2014 10:03 AM

What does the log file say?

oraenthu@live.com 04-05-2014 10:10 AM

no log file gets created.

sgosnell 04-05-2014 10:23 AM

Why are you using both nohup and &? What happens if you don't add the &? The duplication might be part of the problem.

oraenthu@live.com 04-05-2014 10:33 AM

when I execute the script using sh scriptname.sh I cannot see the script as a process if I do a ps -ef|grep scriptname

oraenthu@live.com 04-05-2014 11:32 AM

Please suggest.

schneidz 04-05-2014 11:40 AM

can you show us the output of:
Code:

cat -A your-script-name.ksh
i suspect you are editing this in windows and it is adding cr-lf's to the end of each line.

also try putting the line set -xv as the second line in the script.

oraenthu@live.com 04-05-2014 11:59 AM

Yes I was editing in windows based notepad ++
there is a dollar sign at the end of each line
not sure if it is abnormal
I see that in other files as well
when I run your command
Code:

echo "Executing ${0} ..." >> $LOG_FILE$
$
$ORACLE_HOME/bin/sqlplus -s << EOF >> $LOG_FILE$
$USER_PASSWD$
@$SCRIPTS_DIR/sitecatalyst_session.sql;$
$
EOF$
EXP_LOG=CXD_SITECATALYST_SESSION$
DATE_VAR=`date +"%Y%m"`$
EXP_LOG=$EXP_LOG{$DATE_VAR}$
cat /u02/EXP_DUMP/{$EXP_LOG}.log >> $LOG_FILE$
end_time=`date`$
$
echo " " >> $LOG_FILE$
echo "---------------" >> $LOG_FILE$
echo "Start Time:" $start_time >> $LOG_FILE$
echo "End  Time:" $end_time >> $LOG_FILE$
echo "---------------" >> $LOG_FILE$
$


grail 04-05-2014 12:37 PM

Just to confirm ... all the paths to files used for the script exist?

schneidz 04-05-2014 01:02 PM

Quote:

Originally Posted by oraenthu@live.com (Post 5147168)
Yes I was editing in windows based notepad ++
there is a dollar sign at the end of each line
not sure if it is abnormal
I see that in other files as well
when I run your command
...

i think thats fine as long as there are no ^m's.

try running it with set -xv enabled. or debug it with echo's placed before and after each if.

oraenthu@live.com 04-05-2014 01:27 PM

I place an echo and the echo executes
its only the echo that is executing, nothing else

Update:
okay the password file was missing, when I checked my mail for that subject line, I had about 20 or so mails
there is an exit after that if clause, so if password file is not found, the script exits.

That was fixed and now it works fine.

Thanks so much for your involvement.


All times are GMT -5. The time now is 06:57 PM.