Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Shell Commands executed in perl script

by g_kon (Initiate)
on Jan 04, 2008 at 17:50 UTC ( [id://660442]=note: print w/replies, xml ) Need Help??


in reply to Shell Commands executed in perl script

For some obscure reason, Shell.pm quotes apostrophes (') and backslashes (\) on UNIX, and spaces and quotes (") on Windows. If you set $Shell::raw to true no quoting whatsoever is done, so the only remaining thing to do is to negate the special meaning of characters ',{,},$ inside the awk statement. To be consistent here is an example of what you have to do:
use strict; use Shell; my $sh = Shell->new; $Shell::raw='TRUE'; print $sh->ps("aux | grep firefox | awk \'\{print \$2\}\'");

Replies are listed 'Best First'.
Re^2: Shell Commands executed in perl script
by Anonymous Monk on Apr 29, 2008 at 18:42 UTC
    Man... you saved me: $sh = Shell->new; $Shell::raw='TRUE'; my $EXISTS_= $sh->java("-classpath bpjt-v2.1-3.jar:pmpclient.jar com.mycompany.clients.FilterWithAttributes $CNUM_ID manager"); my $CNUM_MNGR = $sh->echo("\"$EXISTS_\" | grep mng: | gawk -F \",\" \'\{ print \$1 \}\' | gawk -F \"=\" \'\{ print \$2 \}\'"); Thanks, a lot!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://660442]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found