idreesedu has asked for the wisdom of the Perl Monks concerning the following question:

Hello experts attention need I am looking to run a unix shell command in perl script but its getting failing due to pipe "|" and semi colon ";" can any one help me to run folloing command in perl script "p4 -o $valu | sed -e "s/<xxxx>/zzz/g/\;/s/<ggg>/ffff/g" | p4 change -i" above command should run in one shot. THANKS IN ADVANCE

Replies are listed 'Best First'.
Re: Perl Help for using unix command
by Zucan (Beadle) on Jan 09, 2011 at 03:33 UTC

    Can you provide your perl script please? We could better help you. Also, be sure to wrap your code with the "code" tags for readability.

    I see double quotes in the example you provide. Make sure you are being careful with mixed quotes. If you wrapped the entire UNIX command in single quotes, then variable expansion will not work (i.e. $valu will be treated as a string, not as a variable). If you wrapped the UNIX command with double quotes, it will conflict with the double quotes inside the string.

    Once you provide your perl script, we can help further.

Re: Perl Help for using unix command
by GrandFather (Saint) on Jan 09, 2011 at 03:31 UTC

    What is the error message or the observed behaviour that you interpret to be 'failure'? What is the code that you are actually using to execute the shell command?

    True laziness is hard work
Re: Perl Help for using unix command
by matisse (Initiate) on Jan 09, 2011 at 17:50 UTC
    If you want to capture the standard output from that command then this might work for you: my $change_info = `p4 -o $valu | sed -e "s/<xxxx>/zzz/g;s/<ggg>/ffff/g | p4 change -i`; Notice that the semi-colon is not escaped and that there is not a / after the first g in the first sed pattern.