scripts cant work correct


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scripts cant work correct
# 1  
Old 12-20-2005
Power scripts cant work correct

Hi all,

Can any one help me to look on script below.
My script can work correctly.
For the if compare if more than 500 will go to pub.sh -stop
but it go to echo $?.
what happen to the $? , cant use to compare as integer???
Any one please help,urgent...thanks!

#!/bin/ksh

sqlplus -s /nolog <<EOF
connect username/passwd
column num new_value num format 9999
set head off
select count(*) num from pub_queue;
exit num
EOF

if [ $? -gt 500 ]; then
pub.sh -stop
else
echo $?
# 2  
Old 12-20-2005
Try:

return=$?
if [ $return -gt 500 ]; then
pub.sh -stop
else
echo $return
# 3  
Old 12-20-2005
Don't forget your "fi"s people!

Cheers
ZB
# 4  
Old 12-20-2005
Quote:
Originally Posted by zazzybob
Don't forget your "fi"s people!

Cheers
ZB

Oops! I got put but forgot to paste it here. Thanks any way



regards,
Jase
# 5  
Old 12-20-2005
It can't capture the $? into the return.
when i try to echo $return, nothing display...
please help me on this...is it relate to it was sh scripts or ksh scripts????
# 6  
Old 12-20-2005
From the SQL Plus User Guide...
Quote:
Usage
EXIT allows you to specify an operating system return code. This allows you to run SQL*Plus scripts in batch mode and to detect programmatically the occurrence of an unexpected event. The manner of detection is operating-system specific.
[:]
The range of operating system return codes is also restricted on some operating systems. This limits the portability of EXIT n and EXIT variable between platforms. For example, on UNIX there is only one byte of storage for return codes; therefore, the range for return codes is limited to zero to 255.
# 7  
Old 12-23-2005
Now the problem is i can get the value pass from sqlplus but sometime its work somtimes cant...is it because need to clear the $? value first at the beginning of the script????

Please help me on this urgent
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Saltstack commands inside bash scripts donā€™t work

In a Redhat Linux environment, I could run salt commands on the $ prompt but not inside my bash scripts. It will say command not found and the $PATH variable is exactly the same outside and inside the script. !#/usr/bin/bash echo “running”¯ salt "*" cmd.run ‘ls' exit Output:-... (8 Replies)
Discussion started by: gurudewa
8 Replies

2. IP Networking

Discussion at work, would a router work pluging a cable in wan1 and lan1?

hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view situation a router, with linux of some sort, dhcp client requesting for ip in wan1 (as usual with wan ports) dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies

3. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

4. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

5. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

6. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

7. Shell Programming and Scripting

Help with Script using rsh and scripts within scripts

Hi, I've written a script that runs on a Database server. It has to shutdown the Application server, do an Oracle Dump and then restart the Application server. Its been a long time since I wrote any shells scripts. Can you tell me if the scripts that I execute within my script will be executed... (3 Replies)
Discussion started by: brockwile1
3 Replies

8. UNIX for Dummies Questions & Answers

Profile scripts versus rc scripts....

what is the difference between login and profile scripts versus the rc scripts? (1 Reply)
Discussion started by: rookie22
1 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

10. Shell Programming and Scripting

startup scripts, how do they work in UNIX?

I need to make a script to start the postfix service on a server when the machine starts up. I have a script written below, which I think will work, but I am confused on how the rc2.d & rc3.d etc directories actually work. If I enter the script below, and stick it in the rc3.d directory,... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies
Login or Register to Ask a Question