tadakan Posted June 22, 2011 Share Posted June 22, 2011 Hi I've got a problem that I think belongs here, but otherwise please move it. I've been working on this script for a while function runbat($url) { $i = 1; //Set the path and filename $filename = ("C:\\temp\\output".$i.".bat"); //if the file exists renumber the filename and rewrite the variable while(file_exists($filename)){ $i++; $filename = ("C:\\temp\\output".$i.".bat"); } //create the next highest filename and write to the file. $handle = fopen($filename, "a"); $input = "@ECHO OFF \n"; $input .= "SET BROWSER=firefox.exe \n"; $input .= 'START %BROWSER% -new-tab '; $input .= '"'.$url.'"'; fwrite($handle, $input); fclose($handle); $command = "C:\\Windows\\System32\\wscript.exe I:\\emailchecker\\invisible.vbs "; $command .= $filename; echo $command; //execute bat exec($command); //($return_value == 0) or die("returned an error: $command"); sleep(5); unlink($filename); } this block is the function that I think is having the issue, if people are curious I can post the rest. Basically, when I run the whole script in CLI it's all working correctly. When I trigger it with an email through the pipe, it creates the .bat file, waits and then deletes it. But doesn't seem to actually run the script. Thoughts as to why exec (or system() that also) would work in CLI but not when triggered with the email; or at least thoughts regarding how to trace down the problem? Thanks Tom Quote Link to comment https://forums.phpfreaks.com/topic/240079-php-code-behaves-differently-under-cli-than-when-triggered-by-email-pipe/ Share on other sites More sharing options...
tadakan Posted June 22, 2011 Author Share Posted June 22, 2011 I confirmed that it's using php.exe either way. (One method isn't using php-win for example.) So that probably isn't the problem. Quote Link to comment https://forums.phpfreaks.com/topic/240079-php-code-behaves-differently-under-cli-than-when-triggered-by-email-pipe/#findComment-1233206 Share on other sites More sharing options...
tadakan Posted June 22, 2011 Author Share Posted June 22, 2011 Another interesting/frustrating quirk: this regex $reg_exUrl = '%http://appraisalzone.lendervend.com/AssignOrder.aspx.[a-zA-Z0-9/?=&-]{1,}%'; pulls all of the url "http://appraisalzone.lendervend.com/AssignOrder.aspx?orderid=357262&userid=116315&customerorderid=EFC33B67-A60D-434B-99E1-7D4FA5C9DA1C" when run from CLI but only reads through orderid=357262 when run by the email pipe. Quote Link to comment https://forums.phpfreaks.com/topic/240079-php-code-behaves-differently-under-cli-than-when-triggered-by-email-pipe/#findComment-1233217 Share on other sites More sharing options...
tadakan Posted June 23, 2011 Author Share Posted June 23, 2011 I've also tried changing the user account that the email server service starts under, but that didn't change any behavior. Any bright ideas? Quote Link to comment https://forums.phpfreaks.com/topic/240079-php-code-behaves-differently-under-cli-than-when-triggered-by-email-pipe/#findComment-1233678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.