Hello everyone.
I'm having trouble trying to call a php script. I've tried using exec() and phpopen().
Both of these work when I try to call a simple function such as "ls -l", but when it comes to calling an actual php script, I'm having very little luck. It'll work sporadically, but I can't find a pattern.
Here's a quick example:
php.caller
=======
exec("php_test_script.php");
// I've tried this also:
//$handle = popen("php test_script_make_output.php", "r");
//pclose($handle);
php_test_script.php
==============
$iHandle = fopen("output.txt", "w");
fwrite($iHandle, "testing 1");
fclose($iHandle);
I'm trying to write to a file called output.txt when php.caller is executed.
If I run php_test_script.php by itself, it works fine.
Any suggestions would be GREATLY appreciated!
Thanks!
calling php scripts
Moderator: General Moderators
You need to make sure your shell knows how to handle/execute such a file...
Therefor you need to add a "she-bang" line as the first line to your test_script.php
Or you tell explicitely which interpreter that should be used to execute the script in your caller.php:
Therefor you need to add a "she-bang" line as the first line to your test_script.php
Code: Select all
#!/usr/bin/phpCode: Select all
exec('/usr/bin/php test_script.php');-
thegreatone2176
- Forum Contributor
- Posts: 102
- Joined: Sun Jul 11, 2004 1:27 pm
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US