http://www.perlmonks.org?node_id=1052141


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.

Replies are listed 'Best First'.
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