Operating System - HP-UX
1834504 Members
2815 Online
110068 Solutions
New Discussion

How to find out list of spawned program ?

 
J Ramesh Kumar
Advisor

How to find out list of spawned program ?

Hi,

I am trying to change password of an user using expect command. My change password script(cp.sh) is as follows,

-----------------------
#!/bin/sh
#\
exec expect -f "$0" ${1+"$@"}
spawn passwd "testram"
expect "assword:"
send "testpwd\r"
expect "assword:"
send "testpwd\r"
expect eof
-----------------------

The above script works perfectly. But I scheduled this script periodically. It is works most of the cases. But some cases I got the following error message.

-----------------------
pawn passwd user1^M
too many programs spawned? could not create pipe: too many open files
while executing
"spawn passwd "user1""
(file "cp.sh" line 4)^M

-----------------------

From the above error message, it is clear that there are large number of programs spawned. I don't know what are the programs are spawned in the system at that time. Is there any way/command to find out the list of spawned programs ? And also please review my change password script. Is there any spawn cleanup require for that script cp.sh ?

Thanks,
Ramesh
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: How to find out list of spawned program ?

>Is there any way/command to find out the list of spawned programs?

For yourself you can use:
$ UNIX95= ps -Hfu $LOGNAME
J Ramesh Kumar
Advisor

Re: How to find out list of spawned program ?

Hi Dennis,

The following command didn't show the 'spawn passwd' in the list,

#UNIX95= ps -Hfu $LOGNAME

I removed "\r" from my change password script(cp.sh) and tried. If I removed "\r" from the end of password, the spawn will not quit and it will wait for '\r'. So, the "spawn passwd test" is currently active. Now, I tried the above command to identify the process. But it didn't show the corresponding entry. Did I missed anything ?

Thanks,
Ramesh
Dennis Handly
Acclaimed Contributor

Re: How to find out list of spawned program ?

>The following command didn't show the 'spawn passwd' in the list,

Then there isn't a UNIX process for that.
You could add "-x" to the end if you want longer command lines.

>Did I missed anything?

Sorry, I'm not familiar with expect.
James R. Ferguson
Acclaimed Contributor

Re: How to find out list of spawned program ?

Hi Ramesh:

The fact that your failure only occurs periodically along with the message "...to many open files" suggests that you have too low a kernel value for either 'maxuprc' or for 'nproc'. If you are running as root, 'maxuprc' doesn't apply.

You can use 'glance' or 'sar -v' to evaluate yor watermarks.

Regards!

...JRF...