October 3rd, 2013, 03:14 AM
Fopen fails to open a php file
The goal is for one file to open the second file which sends the sms. if i directly start check.php it works but when i try to run it through main.php nothing happens not even an error. suggestions ?
$test = fopen("check.php", "r");
PS i dont want to wait while exec runs , that means main.php needs to run without waiting for a response.
$ping_ex = exec("C:\smssend\SMSUtil /CP COM11 /R \"+37*********\" /M \"test\" ", $ping_result, $pr);
October 3rd, 2013, 03:22 AM
Perhaps it is worth doubling backslashes inside the string.
Why are you trying to fopen it instead of include?
October 3rd, 2013, 03:55 AM
if i directly start check.php it works
tried include it works but waits while exec is running and in my case its ~1minute (feature fof smsutil.exe )
October 3rd, 2013, 04:27 AM
fopen($path, 'r') opens the file for reading. It doesn't execute anything. The only thing you could do with this function call is read the source code of the PHP script, which isn't terribly useful.
If you wanna execute a PHP script from another PHP script, you need to include() it. Note that each script will have access to the variables, constants etc. of the other script.
I wonder why you do this, though. What's the point of having a separate script vs. writing the code directly into the main script or a function?
October 3rd, 2013, 04:31 AM
Execution time , i want for the main file to run while the second files executes the command written in it. Currently if i use include the main file freezes (waits for code in the second file to finish). Trying to call ajax from php to cal another php ... would appreciate a better solution.
Originally Posted by Jacques1
October 3rd, 2013, 04:39 AM
October 3rd, 2013, 04:43 AM
What you really want is to call "exec" asynchronously. It has nothing to do with fopen or inclusion of PHP scripts.
You can google by "php exec asynchronously" for I am not proficient enough in PHP myself. Looks like you need something like this:
October 3rd, 2013, 05:52 AM
Fixed thanks for the replies.
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:\smssend\SMSUtil /CP COM11 /R \"+37**********\" /M $smstext", 0, false);