Jump to content

Need Help with exec()


MetalSmith

Recommended Posts

I am stumped on why when I run a script from DOS using php script.php this will work fine:

 

<?php

echo exec("c:\putty.exe -ssh [email protected] -pw password -m reload.sh");

?>

 

But when I run the same script changing the folder where putty is it won't run:

 

<?php

echo exec("c:\program files\putty.exe -ssh [email protected] -pw password -m reload.sh");

?>

 

What could I be missing?

Link to comment
https://forums.phpfreaks.com/topic/146049-need-help-with-exec/
Share on other sites

Paths to executables must be quoted if they have spaces.

 

 

echo exec("\"c:\program files\putty.exe\" -ssh [email protected] -pw password -m reload.sh");

 

 

Or, more straightforward:

 

echo exec('"c:\program files\putty.exe" -ssh [email protected] -pw password -m reload.sh');

Link to comment
https://forums.phpfreaks.com/topic/146049-need-help-with-exec/#findComment-766719
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.