ticks and FreeBSD

E

Erik Tank

I just migrated a program from RedHat 9 to FreeBSD 5.1. Everything is
working well with the exception of the following:
my @jmail_return_lines = `ps -aux | grep 'jmaild' | grep -v grep`;


The baisc idea is that I want to see if a program called jmaild is
running. On RedHat 9 it @jmail_return_lines would contain the ps -aux
lines but under FreeBSD it returns nothing even though when I take the
command in the ticks and run it from the command line it does return a
line.

Any help or suggestions would be greatly appreciated.

Erik
 
J

James Willmore

I just migrated a program from RedHat 9 to FreeBSD 5.1. Everything
is working well with the exception of the following:
my @jmail_return_lines = `ps -aux | grep 'jmaild' | grep -v grep`;


The baisc idea is that I want to see if a program called jmaild is
running. On RedHat 9 it @jmail_return_lines would contain the ps
-aux lines but under FreeBSD it returns nothing even though when I
take the command in the ticks and run it from the command line it
does return a line.

Any help or suggestions would be greatly appreciated.

You could look into using a module..

Take a look at Proc::Table.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
The light at the end of the tunnel is the headlight of an
approaching train.
 
K

ko

Erik said:
I just migrated a program from RedHat 9 to FreeBSD 5.1. Everything is
working well with the exception of the following:
my @jmail_return_lines = `ps -aux | grep 'jmaild' | grep -v grep`;


The baisc idea is that I want to see if a program called jmaild is
running. On RedHat 9 it @jmail_return_lines would contain the ps -aux
lines but under FreeBSD it returns nothing even though when I take the
command in the ticks and run it from the command line it does return a
line.

Any help or suggestions would be greatly appreciated.

Erik

Works for me, Perl 5.005_03 and 5.8.2 (changed shebang line for 5.8.2).
FreeBSD 4.9 - but that shouldn't matter since the options to grep and ps
are the same:

$ cat ticks && ./ticks
#!/usr/bin/perl -w
use strict;

my @sh = `ps -ax | grep '/bin/sh' | grep -v grep`;
print $sh[0];

452 p1 S 0:00.01 /bin/sh

Have you tried looking for problems elsewhere in the script? Do you have:

use strict;
use warnings;

enabled at the top of the script? If not, that would be a good start.

HTH - keith
 
M

Mike Hunter

I just migrated a program from RedHat 9 to FreeBSD 5.1. Everything is
working well with the exception of the following:
my @jmail_return_lines = `ps -aux | grep 'jmaild' | grep -v grep`;

Freebsd likes ps -ef better.

Mike
 
E

Erik Tank

Although this is getting out of the scope fo this group but -ef only
shows processes associated with your user where as -aux shows them
all.
 
M

Michele Dondi

I just migrated a program from RedHat 9 to FreeBSD 5.1. Everything is
working well with the exception of the following:
my @jmail_return_lines = `ps -aux | grep 'jmaild' | grep -v grep`;

Not an answer to your question, but since nobody has complained yet, I
feel like pointing out that while the above approach is perfectly
"legal", indeed it looks rather awkward too. Why not let Perl use its
own tools to extract the lines you need?

See this (untested) for example:

chomp(my @jmail_return_lines = grep /jmaild/, qx{ps -aux});
^^^^^ ^^^ ^
(1) (2)

(1) bonus chomp(), because you may want it anyway: if not so, then
throw it away,

(2) it's just me, but for some reason I can't stand the backticks
chars :)


Michele
 
M

Michele Dondi

[about reasons for disliking backticks]
Mine is:

There's about 2 pixels difference between "slants" of
single quotes and it makes me squint (ie. slows down
my reading of the code).

Actually I'm not sure myself, but I'd say I do not like them for

(i) they were/are not available on *my* italian keyboard (there are
two possible layouts),

(ii) I learned to use $(...) in (ba)sh instead, that has as an added
value the possibility of nesting,

(iii) probably I'm concerned with their aesthetic appeal: those *two*
"thingies" pointing to the left! In fact I'm not bothered using that
char in TeX's `...' or ``...'', and in that context lots ALT-96's are
not a problem. But then a smart text editor is much better anyway!!


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top