in reply to Re: system command and formatting
in thread system command and formatting

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: system command and formatting
by lakshmananindia (Chaplain) on Feb 27, 2009 at 06:40 UTC

    It works for me.

    split.pl
    $bar=$ARGV[0]; $lak=`$bar`; print "$lak";
    PHP file
    <?php $foo="ls"; $cmd="perl split.pl $foo"; $out=`$cmd`; print "$out"; ?>

    Now the $out has the ls output. I think I understood your question. If not clarify me.

      actually, in the php file, $foo="ID_106", its a string which has to be used in the system command. Example:
      $foo="ID_106"; system("perl split.pl $foo");
      now, the $foo variable is passed to the perl program. the variable $foo is used for system command in perl. example:
      $bar=$ARGV[0]; (the argument input, so now $bar="ID_106") $var=system("grep -A 1 $bar *.txt"); print $var;
      Over here, $var doesnt work :(
      well, that reply is from me.
        I assume Over here, $var doesnt work means $var has nothing in it.

        Did you tried printing the $var to a file?

        When you said print $var, it prints the contents to the STDOUT, which is captured by the system function in PHP. So print $var seems not printing anything, but actually it has the output.

        $bar=$ARGV[0]; $lak=system($bar); print $lak; #This will be captured by the system function in the PHP f +ile. open FH,">> llll"; print FH $lak;

        Now the file will also have the output