给出以下代码:
exec('cmd /c c:'wamp'www'Telnetshutdown.py '.$router);
router变量被正常传递。但是,给定以下代码:
exec('cmd /c c:'wamp'www'Telnetshutdown.py '.$router.' '.$interface);
或
exec('cmd /c c:'wamp'www'Telnetshutdown.py '.$router." ".$interface);
或
$zz=$router.' '.$interface;
exec('cmd /c c:'wamp'www'Telnetshutdown.py '.$zz);
和这些的更多组合…不工作!如何传递多个参数?
尝试使用escapeshellarg来确保您的参数被正确转义
根据这篇文章看来,php将把传递给exec的参数与cmd /c "{{exec argument}}"
框在一起,当它传递给shell时。
Try this:
exec('c:'wamp'www'Telnetshutdown.py '.escapeshellarg($router).' '.escapeshellarg($interface));