Export variable to another script running in background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Export variable to another script running in background
# 1  
Old 05-27-2013
Export variable to another script running in background

i have a script inside which i have generated a background job which will run another script.
How do i export the variables from parent script to the child script which wil run in the background .

a.sh:-

Code:
 
export tmpdir="/usr/tmp"

nohup b.sh&

b.sh:-

Code:
 
echo $tmpdir


But i am not able to print the value of tmpdir in b.sh
# 2  
Old 05-27-2013
Could this help you ?
Code:
$> cat a.sh
#!/bin/ksh
export tmpdir="/usr/tmp"

Code:
$> cat b.sh
#!/bin/ksh
. a.sh
echo $tmpdir

Invocation
Code:
$>chmod +x a.sh b.sh
$>b.sh &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running script in background

Hi, I wrote a KSH script and running it on HP-UX machine I am running one script in background. My script is at location $HOME/myScript/test/background_sh When I view my script in background with psu commend > psu | grep background_sh I see following output UID PID PPID C ... (1 Reply)
Discussion started by: vaibhav
1 Replies

2. Shell Programming and Scripting

Return variable value from a script running in background

I have a script which runs a script in the background. Now the script running in background returns some variable value and i want to catch return value in the parent script. e.g. Parent Script : #!/bin/bash ./Back.sh & pid=$! echo "a=$a" echo "b=$b" echo "d=$((a+b))" wait $pid ... (4 Replies)
Discussion started by: Shaishav Shah
4 Replies

3. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

4. Shell Programming and Scripting

expect_out buffer no such variable running script background

I am trying to use send and receive using expect. the expect_out(buffer) is working fine while it is running it as foreground. But the same script when it is ran as background, the expect_out(buffer) errored out. Is there any factor influence when we run script in foreground and in background? ... (0 Replies)
Discussion started by: shellscripter
0 Replies

5. Shell Programming and Scripting

Export variable, as a background process

Have a script where I need to wait for a process to run, but from that process I want to capture the row count. Script I have so far (easier than explanation): echo "Start" export NUMROWS=`td "select * from dbc.database" 2> /dev/null | grep "Query completed" | sed -e 's/.*Query... (7 Replies)
Discussion started by: Cranie
7 Replies

6. UNIX for Advanced & Expert Users

Running script in background

When I run the following snippet in background #!/bin/ksh while do echo "$i" sleep 10 i=`expr $i + 1` done My job got stopped and it says like + Stopped (SIGTTOU) ex1 & I did "stty tostop" as suggested in many of the post but still not working... (3 Replies)
Discussion started by: shahnazurs
3 Replies

7. UNIX for Dummies Questions & Answers

Running the Script in Background.

Gurus, Pls. help on this to run the script in background. I have a script to run the informatica workflows using PMCMD in script. Say the script name is test.sh & Parameters to the script is Y Y Y Y The no of parameters to the bove script is 4. all are going to be a flags. Each flag will... (2 Replies)
Discussion started by: prabhutkl
2 Replies

8. UNIX for Advanced & Expert Users

send a new value to a variable in a running background process

Hi guys, I have a issue with a background process, I need to update the value of a variable in that process which is running at this time and it will be running for at least 2 days. Any idea? I will apreciate your help. regards. Razziel. (2 Replies)
Discussion started by: razziel
2 Replies

9. Shell Programming and Scripting

How to export a variable from a child process running in background to the parent

Hi All, I have a script which calls a child script with a parameter to be run in the background . childscript.ksh $a & Can any one suggest me how do i export a variable from the child script to parent script? Note that the child script is in background If the child script is in... (3 Replies)
Discussion started by: aixjadoo
3 Replies

10. Solaris

how to capture oracle export log while running as background process

I ran the Oracle 9i export command from a terminal to export out a big table using "exp andrew/password file=andrew.dmp log=andrew.log" From the terminal I can see that the export is running as there is some output from the oracle export job. The export job is not complete yet. When i go check... (4 Replies)
Discussion started by: hippo2020
4 Replies
Login or Register to Ask a Question