LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-05-2014, 08:43 AM   #1
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Rep: Reputation: Disabled
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
 
Old 04-05-2014, 08:52 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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?
 
Old 04-05-2014, 09:36 AM   #3
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
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

Last edited by oraenthu@live.com; 04-05-2014 at 10:19 AM.
 
Old 04-05-2014, 10:16 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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?
 
Old 04-05-2014, 10:26 AM   #5
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.

Last edited by oraenthu@live.com; 04-05-2014 at 11:31 AM.
 
Old 04-05-2014, 11:03 AM   #6
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian
Posts: 1,054

Rep: Reputation: 276Reputation: 276Reputation: 276
What does the log file say?
 
Old 04-05-2014, 11:10 AM   #7
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
no log file gets created.

Last edited by oraenthu@live.com; 04-05-2014 at 11:31 AM.
 
Old 04-05-2014, 11:23 AM   #8
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian
Posts: 1,054

Rep: Reputation: 276Reputation: 276Reputation: 276
Why are you using both nohup and &? What happens if you don't add the &? The duplication might be part of the problem.
 
Old 04-05-2014, 11:33 AM   #9
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
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

Last edited by oraenthu@live.com; 04-05-2014 at 12:28 PM.
 
Old 04-05-2014, 12:32 PM   #10
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
Please suggest.
 
Old 04-05-2014, 12:40 PM   #11
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
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.

Last edited by schneidz; 04-05-2014 at 12:42 PM.
 
1 members found this post helpful.
Old 04-05-2014, 12:59 PM   #12
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
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$
$
 
Old 04-05-2014, 01:37 PM   #13
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Just to confirm ... all the paths to files used for the script exist?
 
Old 04-05-2014, 02:02 PM   #14
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
Quote:
Originally Posted by oraenthu@live.com View Post
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.
 
1 members found this post helpful.
Old 04-05-2014, 02:27 PM   #15
oraenthu@live.com
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.

Last edited by oraenthu@live.com; 04-06-2014 at 03:50 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] execute bash script from pySide script sharky Programming 3 12-23-2013 02:49 PM
[SOLVED] Source or Execute an external Script from shell script helptonewbie Linux - Newbie 2 08-11-2010 01:48 PM
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
Limited user cannot execute a script from within a script, but root can. versaulis SUSE / openSUSE 5 12-01-2008 01:08 PM
script to parse variables to curl script and execute morphix Programming 17 11-30-2007 02:27 AM


All times are GMT -5. The time now is 06:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration