execute command from php on Windows
hej
i'm doing my development on Windows XP with Drupal 4.7 on Apache 2.0.59 with PHP 5.1.6
I'd like to be able to execute a command from a drupal module as if it were typed into the command prompt on windows. My original thought was to set up a cron to run a batch file. But since the parameters of the command will be dynamic, my understanding is that idea won't work (at least not easily). So I came across the exec() command. This however isn't working for me either. I've tried various technics and can't get it to work. My testing now is to just get notepad to open:
$command = 'notepad';
exec($command); exec('start /B "window_name" notepad',$output,$return); $WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C notepad ", 0, true); $WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("notepad.exe", 3, true);I've tried each of those options. Each time the browser just hangs.
My assumption is that its a sceurity issue (probably one that should be in place too). Does anybody know what I might be doing wrong, or have any suggestions on another way to do this.

I played around with the
I played around with the shell_exec command before thinking that it'd be *really* useful... It's not particularly... The only thing I found it useful for was running perl scripts in the background. Check out my fetchgals module for a working example of how to properly use it (unfortunately it's for a linux server, but I'm sure you'll be able to work out what you're supposed to be doing from my work).
...Don't forget... In the case of trying to get notepad to open... You're opening notepad on the server NOT the client computer. So for example, to find the version of perl installed on your server you'd type;
<?php$perl = exec('perl -V:version');
$perl = explode("'", $perl);
$perl = $perl[1];
$form['perl_version'] = array(
'#type' => 'item',
'#value' => $perl ? t('<strong>Perl version:</strong> %ver', array('%ver' => $perl)) : t('Perl is not installed.'),
);
return $form;
?>
Pobster
syntax error makes problem bigger then it seems
thanks to your comment i brought the issue up with a friend of mine for some help with perl syntax - i was in my testing trying to get Notepad to open on the server and he suggested that running GUI through web server wasn't so simple - based on that suggestion i changed my test of exec() to perform a COPY file and low and behold it works perfect - that of course just means the original command i was trying to execute was faulty