shell_exec doesnot work from Browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
haresh
Forum Newbie
Posts: 3
Joined: Wed Mar 12, 2008 1:27 am

shell_exec doesnot work from Browser

Post by haresh »

Hi everyone
I m lunux user and I have to use shell_exec from browser and i have made one script include shell_exec.Its wokring on shell but doesnot work from browser

So anybody can give me solution that what should i do for this.

Regrads,
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: shell_exec doesnot work from Browser

Post by Christopher »

shell_exec() only runs on the server.
(#10850)
radicalfix
Forum Newbie
Posts: 7
Joined: Mon Dec 04, 2006 10:49 pm

Re: shell_exec doesnot work from Browser

Post by radicalfix »

Haresh,

Where do you host the page? Is it from your localhost?
Try the code below and show us what is the result.

Code: Select all

 
<?php
       $cmd = 'set';
       echo "<pre>".shell_exec($cmd)."</pre>";
?>
 
Can you tell us what is the error message you receive?
haresh
Forum Newbie
Posts: 3
Joined: Wed Mar 12, 2008 1:27 am

Re: shell_exec doesnot work from Browser

Post by haresh »

Thanks for giving me reply

I run this scrpit on localhost and doesnt display on browser but on error log it display
"mkdir: cannot create directory `/root/Desktop/haresh123': Permission denied"

and my script is
<?php
shell_exec("mkdir /root/Desktop/haresh123");
?>

pls give me solution for that
haresh
Forum Newbie
Posts: 3
Joined: Wed Mar 12, 2008 1:27 am

Re: shell_exec doesnot work from Browser

Post by haresh »

<?php
$cmd = 'set';
echo "<pre>".shell_exec($cmd)."</pre>";
?>

This php file give output is following

BASH=/bin/sh
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="1" [4]="release" [5]="i686-redhat-linux-gnu")
BASH_VERSION='3.1.17(1)-release'
DIRSTACK=()
EUID=48
GROUPS=()
HOSTNAME=localhost.localdomain
HOSTTYPE=i686
IFS='
'
LANG=C
MACHTYPE=i686-redhat-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/sbin:/usr/sbin:/bin:/usr/bin
POSIXLY_CORRECT=y
PPID=3036
PS4='+ '
PWD=/var/www/html
SHELL=/sbin/nologin
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=3
TERM=xterm
UID=48
_=/usr/sbin/httpd
Post Reply