Jump to content

php code behaves differently under CLI than when triggered by email pipe


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.