Operating System - HP-UX
1834055 Members
2181 Online
110063 Solutions
New Discussion

What is difference between these 2 commands.

 
SOLVED
Go to solution
Prasad Joshi
Regular Advisor

What is difference between these 2 commands.

Hi,

I am running these commands but, not getting difference.

kill -1 `ps -C sleep -o pid
kill -1 `ps -C sleep -o pid=`

see the snap that might help in analyzing.

prasad@prasad:~> sleep 10000 &
[1] 19081

prasad@prasad:~> sleep 10000 &
[2] 19085

prasad@prasad:~> kill -1 `ps -C sleep -o pid`
bash: kill: PID: arguments must be process or job IDs
[1]- Hangup sleep 10000
[2]+ Hangup sleep 10000

prasad@prasad:~> ps -C sleep -o pid
PID

prasad@prasad:~> sleep 10000 &
[1] 19097

prasad@prasad:~> sleep 10000 &
[2] 19101

prasad@prasad:~> ps -C sleep -o pid
PID
19097
19101

prasad@prasad:~> kill -1 `ps -C sleep -o pid=`
[1]- Hangup sleep 10000
[2]+ Hangup sleep 10000
prasad@prasad:~> ps -C sleep -o pid
PID



Thanks in advance.
Prasad.
9 REPLIES 9
Jannik
Honored Contributor
Solution

Re: What is difference between these 2 commands.

A column name can optionally be followed by an equals sign (=) and a string to use as the heading for that column. (Any commas or spaces after the equals sign will be taken as a part of the column heading; if more columns are desired, they must be specified with additional -o options.)
jaton
Peter Godron
Honored Contributor

Re: What is difference between these 2 commands.

Prasad,
what version of OS/kill command are you running:
what `which kill`
ps -o is a XPG4 option only.
man ps will give you the details.
The "=" is the indicator that the next data item is to be used for heading
" A column name can optionally be followed by an equals sign (=) and a string to use as the heading for that column."
Muthukumar_5
Honored Contributor

Re: What is difference between these 2 commands.

a) ps -C sleep -o pid
b) ps -C sleep -o pid=

Difference:

a) will give Heading like PID. But b) will not give heading.

Example:

# UNIX95=1 ps -o pid
PID
27726
6364
6365
# UNIX95=1 ps -o pid=
27727
6364
6365


--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: What is difference between these 2 commands.

From Man ps:

A column name can optionally be followed by an equals sign (=) and a string to use as the heading for that column.

If an empty column heading is specified for every heading, no heading line will be printed.

Refer -o format part. Search key XPG4

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: What is difference between these 2 commands.

Hi Prasad,

Take a look at man ps, it will give you all the details.

http://docs.hp.com/en/B2355-60127/ps.1.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Raj D.
Honored Contributor

Re: What is difference between these 2 commands.

Prasad ,

#man ps & # man kill , along with try it with a dummy kill.

hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Prasad Joshi
Regular Advisor

Re: What is difference between these 2 commands.

This is what i got

bash-2.02# what `which kill`
/usr/bin/kill:
$Revision: B11.23_LR
Fri Aug 29 21:23:26 PDT 2003 $

Thanks
Prasad Joshi
Regular Advisor

Re: What is difference between these 2 commands.

I am having one more question.

It seems stupid, but I am new to Hp-UX. You can understand.

# UNIX95=1 ps -o pid
# UNIX95=1 ps -o pid=

Why variable (may or maynot be variable) UNIX95 is involned in these commands?

What does UNIX95=1 actually mean? What is that '1' for?

Thanks & regards.
Prasad
Prasad Joshi
Regular Advisor

Re: What is difference between these 2 commands.

Thanks a lot for your instant replay.

Got answer.

Thansks & regards.
Prasad