[PHP] Re: system, exec, shell_exec, passthru
No, it not on... safe_mode Off Off safe_mode_exec_dir no valueno value safe_mode_gid Off Off safe_mode_include_dir no valueno value .M Adam Zey wrote: Michael Jonsson wrote: Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = "sudo /usr/bin/webpasswd"; $user=$_POST[name]; $passwd="$passwdexe $user 123456"; echo $passwd; $result = system($passwd); Resultat from the web, "sudo /usr/sbin/webpasswd billy 12345678" and from the error_log, "couldn't read file "./usr/sbin/webpasswd.": no such file or directory". .Mike Notice that "." is being appended before the path, which turns it into a relative path. It looks like safe mode might be on. Create a new PHP script with nothing but the command "phpinfo();" in it, and view it in a browser. To see if safe mode is on, look for the setting "safe_mode". The line below it is "safe_mode_exec_dir". If safe mode is on, you'll need to put your program ("webpasswd") into that directory to execute it. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: system, exec, shell_exec, passthru
Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = "sudo /usr/bin/webpasswd"; $user=$_POST[name]; $passwd="$passwdexe $user 123456"; echo $passwd; $result = system($passwd); Resultat from the web, "sudo /usr/sbin/webpasswd billy 12345678" and from the error_log, "couldn't read file "./usr/sbin/webpasswd.": no such file or directory". .Mike Adam Zey wrote: [EMAIL PROTECTED] wrote: Hello, I am trying the run an external application with command line arguments using PHP under linux. ie: $command="myprog $arg1 $arg2 > textfile.txt"; system("echo \"$command\" > test.txt"); system($command); $handle=fopen("textfile.txt","r"); if($handle!=NULL) { while(!feof($handle)) { ... } fclose($handle); } I test my input arguments for the 'system' call by dumping the command into a text file. I can then test the command in the console. The commands work fine when run from the console. The commands don't work when run through the system command. I have tried system, exec, passthru, and shell_exec to no avail. Am I missing some permissions thing in my php.ini file? Thanks for any insight, Peter Looking at your $command, there is no path in front of it. It's likely that PHP's shell doesn't have the program in its PATH. Try manually specifying the full path to the command: $command="/home/peter/myprog $arg1 $arg2 > textfile.txt"; (or whatever the path is) Keep in mind that under linux, (unlike DOS), you CANNOT execute applications in the same directory without a path. Even if the program is in the same directory as your present working directory (which is usually where the PHP script is located), you'd have to do "./myprog" as a relative path. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Undefined index ????
Hi Why do I get an error if the $_SESSION['user_status'] is emty (it's not set to anything) ??? in my redhat 9 it did mork, but when I moved to Fedora Core 2 it's not working... Script## session_start(); echo $_SESSION['user_status']; #error## Notice: Undefined index: user_status in /var/www/itmdata/include/include.php on line 13 Regards Micke -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Undefined index ???
No, it's not set to NULL it's just emty... .M Torsten Roehr wrote: "Michael Jonsson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi Why do I get an error if the $_SESSION['user_status'] is NULL ??? Script## session_start(); echo $_SESSION['user_status']; #error## Notice: Undefined index: user_status in /var/www/itmdata/include/include.php on line 13 Did you really set it to null?: $_SESSION['user_status'] = null; ? Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Undefined index ???
No, it's not set to NULL it just emty... .M Torsten Roehr wrote: "Michael Jonsson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi Why do I get an error if the $_SESSION['user_status'] is NULL ??? Script## session_start(); echo $_SESSION['user_status']; #error## Notice: Undefined index: user_status in /var/www/itmdata/include/include.php on line 13 Did you really set it to null?: $_SESSION['user_status'] = null; ? Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Undefined index ???
Hi Why do I get an error if the $_SESSION['user_status'] is NULL ??? Script## session_start(); echo $_SESSION['user_status']; #error## Notice: Undefined index: user_status in /var/www/itmdata/include/include.php on line 13 Regards Micke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php