Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: how to use perl variable in system command to run on unix

by toolic (Chancellor)
on Sep 03, 2013 at 16:36 UTC ( #1052141=note: print w/ replies, xml ) Need Help??


in reply to how to use perl variable in system command to run on unix

q prevents variable interpolation. So, $grep_date is not taking on the value 'Sep 02' inside your system call. It remains the literal string $grep_date. Try something like:

my $cmd = 'cd /waslogs1/vfoneLog/cposapp && ls -lrt | grep -i "' . $grep_date . q(" | awk '{ print $9 }' > /home/cpos/CRM_Reports/output/filelis +t.txt); system $cmd;

Also, system returns an exit status, not a command output. Look at qx.


Comment on Re: how to use perl variable in system command to run on unix
Select or Download Code
Re^2: how to use perl variable in system command to run on unix
by tousifp (Novice) on Sep 03, 2013 at 17:25 UTC

    I exceuted your lines like this but no result

    my $cmd = 'cd /waslogs1/vfoneLog/cposapp && ls -lrt | grep -i "'. $gr +ep_date. q(" | awk '{ print $9 }' > /home/cpos/CRM_Reports/output/fil +elist.txt); system $cmd;

    filelist.txt is not written

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-12-22 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (113 votes), past polls