简体   繁体   English

从PHP传递'>'符号到PERL

[英]passing the '>' sign to PERL from PHP

I would like to use PHP to pass two values (I get from a php form) into a perl script in order to process these. 我想使用PHP将两个值(我从php表单中获取)传递到perl脚本中以便处理这些值。 I am able to do this just fine with all characters but not the '>' sign , what can I do to repair this..? 我能够很好地处理所有字符而不是'>'符号 ,我该怎么做才能修复它?

This is my php code: 这是我的PHP代码:

<?php   
    $val="$_POST['val']";
    $val2="$_POST['val2']";
      system("/usr/bin/perl script.pl $val $val2",$retval); 
    if($retval!=0){
        echo ("<p> There was an unknown error.");
    }
?>

Thanks! 谢谢!

system("/usr/bin/perl script.pl '$val' '$val2'",$retval);

If you have ' char in $var1 or $var2, you should escape it. 如果你在$ var1或$ var2中有' char,你应该逃避它。

Anyway, passing $_POST, without sanitize, is very very dangerous! 无论如何,传递$ _POST,没有消毒,是非常危险的!

正如@po_taka已经提到过你需要清理$ _POST数据,使用PHP函数escapeshellarg

system("/usr/bin/perl script.pl ".escapeshellarg($val)." ".escapeshellarg($val2),$retval);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM