ID: 9912 User Update by: [EMAIL PROTECTED] Old-Status: Feedback Status: Open Bug Type: Program Execution Operating system: solaris 7 PHP Version: 4.0.4pl1 Description: exec calls run programs in the document root: different than PHP3 <?php function my_example_func() { global $filename, $output; $cmd = "ls -l " . escapeshellcmd($filename); $out = array(); $rtc = 0; exec($cmd, &$out, &$rtc); if ($rtc == 0) { error_log("The file now exists", 0); $output = implode("<br>", $out); return 1; } else { error_log("Now it doesn't", 0); return 0; } } ?> <!doctype html public "-//W3C//DTD html 4.0 transitional//EN"> <html> <head> <title>Bug 9912</title> </head> <body> <h1>Bug 9912</h1> <p>This php script checks its own existence twice. The log on my system is <pre> [Fri Jun 15 09:46:48 2001] [error] The file now exists ./bug9912.php: No such file or directory Now it doesn't </pre> <p>The function expects the file name on a global variable. To demonstrate the bug we use a relative filename. <?php $filename = "./bug9912.php"; $output = ""; $bb = my_example_func(); register_shutdown_function("my_example_func"); printf("The filename \"$filename\" actually does%s exist", $bb ? "" : " NOT"); printf("<p><code>%s</code></p>", $output); ?> </body> </html> Previous Comments: --------------------------------------------------------------------------- [2001-06-14 16:03:16] [EMAIL PROTECTED] Exec() works just fine for me. Could you please add a complete (but short!) example script? --------------------------------------------------------------------------- [2001-03-22 01:27:00] [EMAIL PROTECTED] Ok, it wasn't that. I'm sorry. The short/long desc should be "exec calls run shutdown functions in root", and A script that has a function with lines like exec("mycommand ./myparam.filename etc", &$srtc, &$rtc); and works when called regularly, stops working if called in a registered shutdown function. Execution is run in the filesystem root. PHP3 scripts with such shutdown functions are broken in php4. --------------------------------------------------------------------------- [2001-03-22 00:39:49] [EMAIL PROTECTED] php3 scripts that have lines like exec("mycommand ./myparam.filename etc", &$srtc, &$rtc); are broken in php4, although easily fixed. I was uncertain whether to post this as a bug or just add a note in http://www.php.net/manual/en/migration4.php I decided for the former since I saw there is a VIRTUAL_DIR that might have expanded popen into virtual_popen, and if that stuff works, perhaps next PHP4 release will have it turned on by default. The workaround on unix might be, for each exec call not on the doc root, # cd /my/doc/root # ln -n -s mydir/mysubdir/myparam.filename . it allows taking further action whenever this bug/feature will be fixed/documented --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=9912 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]