How to execute a script with exit status from bash shell in background ?
=>
[root@host ~]cat /tmp/a
#!/bin/bash
sleep 1
echo 1% complete
sleep 1
echo 10% complete
sleep 1
echo 100% complete
exit 12
[root@host~] (/tmp/a > /tmp/stdout;echo $? > /tmp/ret) &
Verification :
========
[root@puneoshub ~](/tmp/a > /tmp/stdout;echo $? > /tmp/ret) & <----------- way to execute.
[1] 24110
[root@puneoshub ~]
[1]+ Done ( /tmp/a > /tmp/stdout; echo $? > /tmp/ret )
[root@puneoshub ~]cat /tmp/stdout /tmp/ret
1% complete < ----- STDOUT
10% complete
100% complete
12 < ----- RETURN
=>
[root@host ~]cat /tmp/a
#!/bin/bash
sleep 1
echo 1% complete
sleep 1
echo 10% complete
sleep 1
echo 100% complete
exit 12
[root@host~] (/tmp/a > /tmp/stdout;echo $? > /tmp/ret) &
Verification :
========
[root@puneoshub ~](/tmp/a > /tmp/stdout;echo $? > /tmp/ret) & <----------- way to execute.
[1] 24110
[root@puneoshub ~]
[1]+ Done ( /tmp/a > /tmp/stdout; echo $? > /tmp/ret )
[root@puneoshub ~]cat /tmp/stdout /tmp/ret
1% complete < ----- STDOUT
10% complete
100% complete
12 < ----- RETURN
No comments:
Post a Comment