thebeaniemonster has asked for the wisdom of the Perl Monks concerning the following question:
Hi
Please forgive if this is a stupid question but I'm a bit stuck and wondered if you could help?
I have a perl program that gets information about running processes on a server. I have a command that works on the command line but I can't get it to work in my perl script.
The command that works on the command line is:
ps aux | grep java | perl -e 'while(<STDIN>){if (/-Xmx((\d+)[gG])/) { +$mem += $2 } } print "total memory reserved by Java processes: ${mem} +G\n"'
Which gives me: total memory reserved by Java processes: 58G
If I post this into my perl script no matter how I tweak it I can't get it to work.
Can you please help?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running a command in Perl
by davido (Cardinal) on Jan 28, 2014 at 16:52 UTC | |
|
Re: Running a command in Perl
by Tux (Canon) on Jan 28, 2014 at 17:37 UTC | |
|
Re: Running a command in Perl
by Laurent_R (Canon) on Jan 28, 2014 at 19:45 UTC |