Page 1 of 1

shell_exec doesnot work from Browser

Posted: Wed Mar 12, 2008 1:34 am
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,

Re: shell_exec doesnot work from Browser

Posted: Wed Mar 12, 2008 2:37 am
by Christopher
shell_exec() only runs on the server.

Re: shell_exec doesnot work from Browser

Posted: Wed Mar 12, 2008 3:48 am
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?

Re: shell_exec doesnot work from Browser

Posted: Thu Mar 13, 2008 4:05 am
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

Re: shell_exec doesnot work from Browser

Posted: Thu Mar 13, 2008 4:09 am
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