Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bourne Shell Script 1

Status
Not open for further replies.

greju

Programmer
Oct 20, 2003
7
US
I execute the following at the command prompt

=>SNMP_PORT=10000 /usr/sbin/hostmibd -d 128 &
=>SNMP_PORT=10000 /usr/sbin/snmpmibd -d 128 &

I want to put these statements in a bourne shell script. If I put these exactly as it is, I find that the two stop execution after a few seconds. However at the command prompt they execute indefinitely unless we kill the jobs ? Is it possible to get the exact behavior as I get in the command prompt by putting these in a script ? How different is background processing when we execute in a script ?

Thanks
Reju
 
Have you tried it without the & at the end of the lines in the script?
 
Well this page suggests the program should be started using something called 'startsrc'
Is this the hostmibd you're running?

> How different is background processing when we execute in a script ?
There are a few subtle differences, like exactly where stdin and stdout are, and the parent process of the background processes.

For example, if you have a script and you type
Code:
./script
then a short-lived process is created to run your background processes, and then it exits. Effectively, this means that the two processes you created are now orphans, and they become children of 'init'

If on the other hand you type
Code:
source script
you run the commands exactly as if you had typed them in manually, and the background processes remain children of your shell (until you quit from your shell)

You also might read about 'nohup', which shields a process from some of the signals which may affect the parent process at some later time.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top