Weird problem in my shell script,please help me!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Weird problem in my shell script,please help me!!!
# 1  
Old 08-03-2010
Weird problem in my shell script,please help me!!!

Code:
sqlLogftp_mov=$LOGDIR/logftp_mov_$mydate.log
sqlplus -s $ORAUSER << EOF > $sqlLogftp_mov
SET SERVEROUT ON
@/$SCRIPTDIR/rep_comm_ext_tbl_load.sql
EOF
retorno=0
cnt=`grep -q 'ORA-' $sqlLogftp_mov | wc -l`
if [ $cnt -gt 0 ]; 
then
retorno=1
echo 'Failure'
sendEmailFalha
exit 1
fi
if [ $retorno -eq 0 ];
then
echo 'Success' 
sendEmailSucesso 
exit 0 
fi

In the above shell script,I called a sql script.It worked super cool but the problem is
I couldn't use that grep,it throws the error.
"grep: 0652-033 Cannot open /sharedapps/etlusr/etl/logs/logftp_mov_03082010061856.log."
I think the control is not flowing back to shell after calling sql script.
Even I tried putting a " echo 'hi' " after the EOF in the above script,on running the script I am not getting the echo printed and only shows the above error.

Any help in this case will be very helpful..Thanks

Last edited by shyamaladevi; 08-03-2010 at 08:23 AM.. Reason: code tags; remove extraneous formatting
# 2  
Old 08-03-2010
If the other application still has it open, you might try to sleep just before grep:
Code:
sleep 1

But the grep command has a problem. The -q switch makes it quiet. Try this instead:
Code:
cnt=`grep -c 'ORA-' $sqlLogftp_mov`

# 3  
Old 08-03-2010
Thanks for the quick reply.
I tried using sleep 1 grep -c but I am still getting the same error Smilie

---------- Post updated at 07:51 AM ---------- Previous update was at 06:21 AM ----------

Quote:
Originally Posted by KenJackson
If the other application still has it open, you might try to sleep just before grep:
Code:
sleep 1

There is no other application which is keeping it open;I am just thinking that after calling the script,the control is not flowing to shell.
Even the echo statement after EOF is not executing..
# 4  
Old 08-03-2010
hi,
Code:
sqlplus -s $ORAUSER << EOF > $sqlLogftp_mov
SET SERVEROUT ON
@/$SCRIPTDIR/rep_comm_ext_tbl_load.sql
exit;
EOF

add "exit;" before EOF and try to execute the script
# 5  
Old 08-03-2010
Hi Pravin,

I tried with exit; before EOF but it is still throwing the same error Smilie
# 6  
Old 08-04-2010
what's the sql file doing? that's weird that you'd get a grep error prior to an echo..
# 7  
Old 08-04-2010
grep: 0652-033 is a "file not found" error. Have you checked that /sharedapps/etlusr/etl/logs/logftp_mov_03082010061856.log exists? I don't know sql, is it creating the file with it's output? Maybe if there's no output, it's not creating it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Weird awk problem

Hi, I have a simple awk script: BEGIN{} { $a=$2-$1; print $a } END{if(NR==0){ print "0" } } to which I provide the following input 2.9 14 22.2 27 (4 Replies)
Discussion started by: jamie_123
4 Replies

2. Shell Programming and Scripting

Weird Exit Status of shell script

I have a script named check which will read the content of a file and check wether those files exist in the current directory. If so it will have the exit status of 0, otherwise it will have 1. check script: #!/bin/bash if ; then #Check there is enough command line parameters. exit 1... (2 Replies)
Discussion started by: Ray Sun
2 Replies

3. Shell Programming and Scripting

share a shell script which can replace weird characters in directory or file name

I just finish the shell script . This shell can replace weird characters (such as #$%^@!'"...) in file or directory name by "_" I spent long time on replacing apostrophe in file/directory name added: 2012-03-14 the 124th line (/usr/bin/perl -i -e "s#\'#\\'#g" /tmp/rpdir_level$i.tmp) is... (5 Replies)
Discussion started by: begonia
5 Replies

4. Programming

A weird problem with POSIX function

Hi all, Sorry for the title because I didn't find a proper name for it. My question is about POSIX functions, such as timer_create(), mq_open() and pthread_create(). void test_queue() { struct mq_attr attr; attr.mq_maxmsg = 10; attr.mq_msgsize = 64; mq_unlink("/my_test_queue");... (6 Replies)
Discussion started by: bus147
6 Replies

5. Shell Programming and Scripting

awk weird problem.

awk 'BEGIN{print 1.2.3.4}' 1.20.30.4 Can anyone explain why has extra "0" in the IP address? (3 Replies)
Discussion started by: newoz
3 Replies

6. AIX

weird korn shell script

here is the one of the scripts: script1.kshfunction haha { print "calling haha" exit } script2.ksh. script1.ksh haha | tee -a /dev/null print "i am script 2" after launching the script2, the result: --------------------------------------------- calling haha i am script 2 ... (6 Replies)
Discussion started by: getter
6 Replies

7. Infrastructure Monitoring

Weird dependency problem!

Hi, I want to install net-snmp-devel package but i have following dependecy problem. It's very odd, i don't get it. One of packages is depended on the other one, the other one is depended on the previous one as well. :S :S Could you help me please? Here are the steps: # ls -l total... (4 Replies)
Discussion started by: oduth
4 Replies

8. UNIX for Advanced & Expert Users

Really weird delete problem

Hi, I've Ubuntu 8.04, and it has some files that I just cannot delete. I've tried everything, inode, fsck etc. Here is what the ls -li outputs root@ubuntu:/home/luser/.local/share/Trash/files/junk# ls -l ls: cannot access TRUNK_: No such file or directory ls: cannot access 2006_output.mv:... (11 Replies)
Discussion started by: nitin
11 Replies

9. Solaris

Weird crontab problem

Greetings To All! I am running Solaris 10 in a sparc environment. Here is the deal: In /var/spool/cron/crontabs, there is a cron user named "sys". If I do a crontab -l sys, it returns: # 0 * * * 0-6 /usr/lib/sa/sa1 # 20,40 8-17 * * 1-5 /usr/lib/sa/sa1 # 5 18 * * 1-5 /usr/lib/sa/sa2... (8 Replies)
Discussion started by: RobSand
8 Replies

10. UNIX for Dummies Questions & Answers

Weird Problem???

I have a problem I don't understand... I am trying to declare a variable, and then output the results of that variable, couldn't be simpler #!/bin/ksh VAR='Oranges' if then echo "Found Lemons" elif then echo "Found Oranges" fi The output shouold clearly be "Found Oranges", but... (2 Replies)
Discussion started by: danhodges99
2 Replies
Login or Register to Ask a Question