How to execute same script independently?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to execute same script independently?
# 1  
Old 05-30-2013
How to execute same script independently?

Hello All,

I have one script for example a1.sh. I want to execute the same a1.sh script inside a1.sh script at the end with different parameter such that the second one will run independently. I don't want the second one to take any input from 1st a1.sh. I tried few things like background/exec etc but no luck.

Thanks
Vikram
# 2  
Old 05-30-2013
Could this help you ?
a1.sh
Code:
#!/bin/ksh
if [ "$1" == "RUN" ]
then
        echo "With argument"
        sleep 5
        echo "finished"
        exit 0
fi
echo "Without argument"
a1.sh "RUN" &

# 3  
Old 05-30-2013
Try using nohup

That should help you! Smilie
# 4  
Old 05-30-2013
This is my scenario

Iam running this script as the main script

Code:
./app1.sh -e envxxws -b DUMMY -c BPEL configure deploy

and the below one is the one which iam using at the end of this script and it should be run independently

Code:
while read file
do
/apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy 
done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst
exit

# 5  
Old 05-30-2013
Code:
while read file
do
/apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy 
done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst
exit

is this the complete script?

If yes, then replace the line /apps/psr/build_dev/vtanwar/app1.sh -e "$Env_Name" -b DUMMY -c BPEL -p $file undeploy

as nohup /apps/psr/build_dev/vtanwar/app1.sh -e "$Env_Name" -b DUMMY -c BPEL -p $file undeploy & This should resolve it Smilie
# 6  
Old 05-30-2013
How about this
Code:
nohup sh -c 'while read file; do /apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy; done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst' &
exit

# 7  
Old 05-30-2013
@pravin27: why put that while loop in nohup?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute a script based on status of embedded script

Hi, I have 2 scripts, first.ksh and second.ksh and would like first.ksh to run based on response of 'Y/y' received for second.ksh but in my case it continues to execute 'rm /tmp/list' irrespective of response received, below are my scripts with further info, Hope I'm making sense :) Thanks! ... (1 Reply)
Discussion started by: mbak
1 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. UNIX for Dummies Questions & Answers

Sort each column independently

Hi, I have a file full of this fields and rows: 0.269330|0.035118|0.526763|0.792274 0.33555|19.471911|51.844968|1631 ... 3.981490|5.062725|17.190744|111 0.000000|0.030234|0.000000|1631 ... ... I'd like to sort EACH column individually based on the value after the third "|".... (12 Replies)
Discussion started by: a_bahreini
12 Replies

4. Linux

How to execute a simple select script using a shell script?

Hi team, I have two select statements and need to run them using SYSDBA user select * from temp_temp_seg_usage; select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; Need to run this using a shell script say named... (1 Reply)
Discussion started by: pamsy78
1 Replies

5. Solaris

Need to execute the script with script name wihtout using ./scriptname in Solaris 10

Hi, I am using solaris 10.Is there any way to execute the script with the scriptname wihtoug using ./scriptname?Also does it varies from shell to shell.I have scripts in bash,ksh,sh shells. Example:script.sh is the script name.I need to execute the script like this script.sh instead... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

6. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

7. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

8. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

9. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

10. Shell Programming and Scripting

script execute or no execute

o hola.. Tengo un script que se ejecuta bajo una tarea del CronJOb del unix, tengo la version 11 de unix, mi script tiene un ciclo que lee unos archivos .txt luego cada uno de esos archivos debe pasar por un procedimiento almacenado el cual lo tengo almacenado en mi base de datos oracle 10g,... (4 Replies)
Discussion started by: Kespinoza97
4 Replies
Login or Register to Ask a Question