sanchez77 Posted June 2, 2012 Share Posted June 2, 2012 I'm using the PSTools psexec tool tp execute a script. But I can't figure out how to pass arguments to it. I've tried exec('C:\PSTools\psexec -d "C:\Program Files (x86)\PHP\php-cgi.exe" C:\inetpub\wwwroot\bkupdate.php "$var1" "$var2" ' ); exec('C:\PSTools\psexec -d "C:\Program Files (x86)\PHP\php-cgi.exe" C:\inetpub\wwwroot\bkupdate.php <$var1 $var2> ' ); and exec('C:\PSTools\psexec -d "C:\Program Files (x86)\PHP\php-cgi.exe" C:\inetpub\wwwroot\bkupdate.php [$var1 $var2] ' ); Has anyone done something similar? Doe anyone know how to do that? Thanks, sanchez Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/ Share on other sites More sharing options...
trq Posted June 3, 2012 Share Posted June 3, 2012 Variables are not interpolated within single quotes. Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350713 Share on other sites More sharing options...
sanchez77 Posted June 3, 2012 Author Share Posted June 3, 2012 so does that mean i can't use exec to execute psexec and pass variables to it? Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350718 Share on other sites More sharing options...
trq Posted June 3, 2012 Share Posted June 3, 2012 No, it means that variables do not interpolate within a single quoted string. Try: exec("C:\PSTools\psexec -d 'C:\Program Files (x86)\PHP\php-cgi.exe' C:\inetpub\wwwroot\bkupdate.php '$var1' '$var2'"); Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350726 Share on other sites More sharing options...
sanchez77 Posted June 3, 2012 Author Share Posted June 3, 2012 Thanks, but the script never ran using that. Should i use shell_exec instead? Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350733 Share on other sites More sharing options...
trq Posted June 3, 2012 Share Posted June 3, 2012 Try it. Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350737 Share on other sites More sharing options...
sanchez77 Posted June 4, 2012 Author Share Posted June 4, 2012 i did....and it didn't work Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1350966 Share on other sites More sharing options...
soiswis Posted June 19, 2012 Share Posted June 19, 2012 add this psexec -accepteula Link to comment https://forums.phpfreaks.com/topic/263550-exec-psexec/#findComment-1355134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.