Re: Shell script "threads" (523 Views)
Reply
Regular Advisor
Posts: 131
Registered: ‎07-20-1998
Message 1 of 10 (523 Views)
Accepted Solution

Shell script "threads"

We run scripts that execute Oracle SQLs, most of them with multiple "steps". It seems there are cases where a 'ps -ef' will show the "shell script" and sometimes not, even though one of it's "steps" (SQL Scripts) are executing. Suffice it to say I find it a little difficult to follow the thread when a programmer asks me to kill the "shell script" but they don't know what "step" it's in.
Insecurity is our friend. It keeps you dependent.
Honored Contributor
Posts: 1,366
Registered: ‎08-17-2003
Message 2 of 10 (523 Views)

Re: Shell script "threads"

is the SQL script is a subprocess from shell script, then shell script can't "disappear" while SQL still running.

In order not to miss the shell, you can use this command : "UNIX95=true ps -AH -o user,pid,args" which will show you processes in a tree form. You can use grep to get only processes hold by the user you want.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Regular Advisor
Posts: 131
Registered: ‎07-20-1998
Message 3 of 10 (523 Views)

Re: Shell script "threads"

Fred-
Well, I suppose I should have been more specific. According to the "man" pages for "ps" the -A and -H options are only valid for XPG4. I am certain that your solution would work swell in such a case. To be honest with you, I don't even know what XPG4 is, but I do know that I get an error when I try to use these options. I am on HPUX 11.00
Insecurity is our friend. It keeps you dependent.
Honored Contributor
Posts: 1,461
Registered: ‎03-10-1998
Message 4 of 10 (523 Views)

Re: Shell script "threads"

I have HPUX 11.0 and I have no problem running the command
UNIX95= ps -AH -o user,pid,args | grep

Regards
Jean-Luc
fiat lux
Regular Advisor
Posts: 131
Registered: ‎07-20-1998
Message 5 of 10 (523 Views)

Re: Shell script "threads"

# UNIX95=`ps -AH -o user,pid,args | grep sched`
ps: illegal option -- A
ps: illegal option -- H
ps: illegal option -- o
usage: ps [-edaflPx] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup]

Perhaps mistakenly I removed the spaces and replaced them with "back tics",
But thanks anyway.
Insecurity is our friend. It keeps you dependent.
Honored Contributor
Posts: 1,461
Registered: ‎03-10-1998
Message 6 of 10 (523 Views)

Re: Shell script "threads"

no backquote !!!
just a space between UNIX95= and ps command

Regards
Jean-Luc
fiat lux
Regular Advisor
Posts: 131
Registered: ‎07-20-1998
Message 7 of 10 (523 Views)

Re: Shell script "threads"

So, what is "UNIX95". I can't find a man page for it and "which" returns nothing. That construct looked like an "assign" to me(?).
Insecurity is our friend. It keeps you dependent.
Honored Contributor
Posts: 1,461
Registered: ‎03-10-1998
Message 8 of 10 (523 Views)

Re: Shell script "threads"

Honored Contributor
Posts: 1,366
Registered: ‎08-17-2003
Message 9 of 10 (523 Views)

Re: Shell script "threads"

I made it a little short maybe :)

Switching in XPG4 mode can be done by setting UNIX95 env variable to anything you want (for exemple to "true").

In Unix, you can do the following :
. Have a var defined for your shell, using "UNIX95=true"on a single line.
. Have a var defined for your shell and sub-shells, using "export UNIX95=true" on a single line
. Have a var defined only for the current command, using "UNIX95=true whatevercommandyouwant".

I used the last one. So you have to do exactly the following :
UNIX95=true ps -AH -o user,pid,args
(note the space between "UNIX95=true" and "ps".)

I only set UNIX95 for this command, because this XPG4 environment has consequences for many commands and I don't want your environment to be changed.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Regular Advisor
Posts: 131
Registered: ‎07-20-1998
Message 10 of 10 (523 Views)

Re: Shell script "threads"

Fred - thanks for the reply.
Insecurity is our friend. It keeps you dependent.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.