D
dn_perl
I am using backticks in two places in a perl script. One instance
is returning the expected result. The other one has me confused.
1) my @list_of_ipcs = `ipcs -q -p | grep "0x" ` ;
This command works the way I would expect it to.
2) my @related_list = `ps -ef | grep $id_parent_proc | grep 16 ` ;
Let us say, $id_parent_proc = "44556"
The above statement creates @related_list as an array with two rows.
If I run the command from the shell : ps -ef | grep 44556 | grep 16 ,
it retruns only one line. I thought backticks would also create
an array with just one column.
But here is what I get :
$related_list[0] ===> " userA 6161 6157 0 17:01:28 pts/1
0:00 sh -c ps -ef | grep 44556 | grep 16"
$related_list[1] ===> " userA 44556 1 0 Dec 22 ?
0:01 daemon_proc 16 /vol1/apps/mydir................. "
How can I eliminate that 0-th entry in the @related_list array ?
One more question while I am it.
When I run : ps -ef | grep 5000
I almsot always get at least one row in return, the row which says :
userA 6598 5464 0 17:07:36 pts/1 0:00 grep 5000
But sometimes I don't find any row returned as response.
What could be the reason?
TIA.
is returning the expected result. The other one has me confused.
1) my @list_of_ipcs = `ipcs -q -p | grep "0x" ` ;
This command works the way I would expect it to.
2) my @related_list = `ps -ef | grep $id_parent_proc | grep 16 ` ;
Let us say, $id_parent_proc = "44556"
The above statement creates @related_list as an array with two rows.
If I run the command from the shell : ps -ef | grep 44556 | grep 16 ,
it retruns only one line. I thought backticks would also create
an array with just one column.
But here is what I get :
$related_list[0] ===> " userA 6161 6157 0 17:01:28 pts/1
0:00 sh -c ps -ef | grep 44556 | grep 16"
$related_list[1] ===> " userA 44556 1 0 Dec 22 ?
0:01 daemon_proc 16 /vol1/apps/mydir................. "
How can I eliminate that 0-th entry in the @related_list array ?
One more question while I am it.
When I run : ps -ef | grep 5000
I almsot always get at least one row in return, the row which says :
userA 6598 5464 0 17:07:36 pts/1 0:00 grep 5000
But sometimes I don't find any row returned as response.
What could be the reason?
TIA.