olkhicha_appa Posted April 2, 2007 Share Posted April 2, 2007 hello, If I have following In two files, and I serve foo.php then I notice If I use commandline execution i.e. php foo.php then foo.txt is touched/created all right. i.e. system command is executed as expected But If I use browser then I notice that the shell command in config.php is *not* executed Any ideas as to why this might be happening? ---------- config.php <?php bar = system('touch foo.txt'); ?> and in foo.php <?php require(('config.php'); dummy = system('ls -la foo.txt'); echo "$dummy"; ?> Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/ Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 its probably disabled from your server or your server is a windows box, any errors ? Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219630 Share on other sites More sharing options...
olkhicha_appa Posted April 2, 2007 Author Share Posted April 2, 2007 Its a linux box Linux <server-name> 2.6.9-022stab078.9-enterprise #1 SMP Thu Jun 8 12:38:51 MSD 2006 i686 athlon i386 GNU/Linux And no I dont see any errors. Short of asking to hosting guys, how can I find out if executing shell commands is disabled? Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219632 Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 check phpinfo(); to see if your in safe mode Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable. Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219637 Share on other sites More sharing options...
olkhicha_appa Posted April 2, 2007 Author Share Posted April 2, 2007 No.. the safe_mode is "off". Any ideas? Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219657 Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 ok well if system('ls -la foo.txt') isn'ty working then their probably disabled oh as a note the code dummy = system('ls -la foo.txt'); echo "$dummy"; should be $dummy = system('ls -la foo.txt'); echo "$dummy"; Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219660 Share on other sites More sharing options...
olkhicha_appa Posted April 2, 2007 Author Share Posted April 2, 2007 I solved it. I just avoided using system/exec and instead used [code]<?php $var=`unix_command`;?> instead. This seems to do the trick.[/code] Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219662 Share on other sites More sharing options...
olkhicha_appa Posted April 2, 2007 Author Share Posted April 2, 2007 I solved it. I just avoided using system/exec and instead used <?php $var=`unix_command`;?> instead. This seems to do the trick. Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219684 Share on other sites More sharing options...
olkhicha_appa Posted April 2, 2007 Author Share Posted April 2, 2007 I am sorry but I called victory too quickly. I have a much smaller example. The actual code is <?php $foo=system('touch foo.txt',$boo); if($boo == 1) $url ="http://"; else $url="foo.txt"; echo '<html>',"\n\n"; echo 'The link to the generated file is <a href=', $url, '>foo.txt</a>',"\n\n"; echo '</html>',"\n\n"; ?> If you do above on command line the URL is fine(i.e. exit status of system() is 0) but if you use browser you will notice the exit status is 1 For seeing the reult http://kher.org/bug.php. Alternatively, save the code locally and execute on command line. It also has php info. Link to comment https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/#findComment-219698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.