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

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.

Replies are listed 'Best First'.
Re^4: system command and formatting
by Anonymous Monk on Feb 27, 2009 at 06:57 UTC
    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 :(
Re^4: system command and formatting
by sugar (Beadle) on Feb 27, 2009 at 06:59 UTC
    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