Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Shell Commands executed in perl script

by rinceWind (Monsignor)
on May 22, 2007 at 11:08 UTC ( #616729=note: print w/replies, xml ) Need Help??


in reply to Shell Commands executed in perl script

You have quotes inside your quotes. Try the following:

print $sh->ls( qq(-l ./logs/ |grep -v "^d" |grep -v file1 | awk 'NR>1 +{ print \$9}'));

Or indeed you could use q() as you're not doing any variable substitution inside the string.

Update: yes I know it would be better for the OP to have coded this in perl rather than shelling out 4 subprocesses. Sometimes you need to start with where the person is. Spotting the quote nesting is something glaringly obvious to me - a kind of mistake anyone can make in coding, and worth pointing out.

--
wetware hacker
(Qualified NLP Practitioner and Hypnotherapist)

Replies are listed 'Best First'.
Re^2: Shell Commands executed in perl script
by msk_0984 (Friar) on May 22, 2007 at 11:43 UTC
    Hey rinceWind

    Really thanx for your prompt reply ..... but i am facing another problem after making the changes, when executed it is giving me the error. Even used q() also but no success

    awk: 'NR
    awk: ^ invalid char ''' in expression

    Work Hard Party Harderrr!!
    Sushil Kumar
Re^2: Shell Commands executed in perl script
by Anonymous Monk on May 22, 2007 at 13:24 UTC
    Dude ... Do you really need to use Shell at all ??? Convert this shell to perl code...will probably take less time then debugging this errors one at a time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://616729]
help
Chatterbox?
[Corion]: erix: I'm not sure if it really is MySQL - maybe MS SQL also has LIMIT 0
[erix]: it has TOP, IIRC
[Corion]: erix: Ah. I use where 1 = 0 for queries where I only am interested in the structure ;)
[erix]: 1=0 is as short as TOP :)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-01-23 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (192 votes). Check out past polls.