Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





System/exec Not Working In Browser


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 expectedBut If I use browser then I notice that the shell command in config.php is *not* executedAny ideas as to why this might be happening? Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Exec, Shell_exec, System, And Passthru Not Working At All
Can't get these commands to work! The following page simply doesn't
finish loading ( Waiting... Opening... :-( )

<?php echo system("dir"); ?>

The same for <?php echo exec("dir"); ?> or <?php echo
shell_exec("dir"); ?>, etc...

I'm running Apache 2.0.55 & PHP 5.0.5 with Zend Optimizer v2.5.10 on
windows XP SP2.

View Replies !
System(); Command Not Working On Remote System. Windows.
My server is a windows machine, on the same domain as python(also a windows machine). Apache is running as a service as an administrator. This is a test only environment to whom it may concern(I hate people telling me how insecure my system is) I'm just trying to run:

$last_line = exec('dir pythonc$', $retval, $g);
print_r($retval);
echo '<br>'.$g.'<br>';
echo '$last_line= '.$last_line.'<br>';
Which outputs:

Array ( )
1
$last_line=

The command from the command line works fine. And apache can access directories that only administrators can access on the local machine.

View Replies !
PHP System() And Exec()
Background: I am trying to execute a binary on the server located in the current directory where the php script is being run. The server is a linux (debian based). I am having trouble getting php to execute the binary properly, below is my code. Code:

View Replies !
System() And Exec()
If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

I have tried numerous time by redirecting to a file or other stream to free up a php web page that called a perl script for example, but the php script always hangs...has anyone had any luck freeing up a calling php script from a process, or program that it launched in the background? Code:

View Replies !
Exec(), System()
I write very, very simple script who call external program. The script is run on Linux Slackware, Apache/1.3.37 (Unix) mod_ssl/2.8.28 OpenSSL/0.9.8b PHP/4.4.4 here is my script:

<?php
echo exec('ls');
?>
this work properly.

but if i write:

<?php
echo exec('xine'); //xine is a multimedia player
?>

View Replies !
Bug In System And Exec Commands
If PHP is running via a web server, and mutiple system
calls are made within the script to another script,
hundreds of processes are created. Here is an example:

Script 1:
<?php
for ($i=1; $i<=5; $i++) {
system("php script2.php");
}
?>

Script 2:
<?php
exit;
?>

The effect is the same (and more difficult to stop) when
the system calls are made in the background. e.g.

system("php script2.php >>/dev/null 2>>/dev/null &");
system("php script2.php >/dev/null 2>&1");

I have even tried calling a shell script, which in turn
calls the second PHP script (both in the background), but
it still causes lots of processes.

The "exec" command is also affected.

At first, I thought this was a problem with either Zeus web
server of Fast CGI, but I have since tried it with Apache
and normal CGI with the same effect.

Does anyone have any idea why this happens and whether there is any way to prevent it? I have posted a bug report to bugs.php.net (ID 14997), but so far to no avail.

View Replies !
System() Or Exec() And Permissions
I'm trying to run a command (mogrify) that requires that I'm logged in as root, or at least I think this is the case. How can I do this?

View Replies !
Exec() And System() Problems
I am trying to use php's exec() or system() to execute a shell script that I wrote.

exec and system() work fine with a simple command like ls, but nothing happens when I point it at the shell script.

The shell script works fine from my shell login. Can't figure out what tho problem is. Is php just incapable of running shell scripts?

View Replies !
Using Passthru(), Exec(), System() Etc.
I have an executable that runs as expected from a command prompt but seems to do nothing when I try to run it from php, using passthru(), exec(), etc.

View Replies !
System/shell/exec/etc
I've got PHP 5.1.6, Apache 2.2.2, on Fedora 5. Everything is great except that when I use an of the external launching commands, persistent apps dont stay open. I have a simple shell script set up to load an app, and I have it write a PID file. Immediately after calling exec (milliseconds later) the PID is alive. However, within a few more milliseconds it seems to close.

I've made sure that the apache uid/gid have full access to the script and the apps it calls. When sudo'ing manualy in a shell with the apache uid, the script works flawlessly and loads the program, and stays open, as it should. I've verified that the app loads under the uid 'apache' with ps. When running it through PHP, it seems to close almost immediately after succeeding.

Is there some fundamental issue with how this works that I'm missing? I can't seem to get any real errors out of php, apache, or even the shell when redirected to a file. Should I try PHP4? Is PHP5 buggy with this kind of thing? I even tried running 'at' to schedule the script (so that it'd be invoked by at instead of the shell itself) but that failed, silently, as well.

View Replies !
Exec(), System() And Win 2003
I have searched high and low for the past 2 days for an answer to my problem. I have found a few references, but nothing has helped me. My problem is this: I am trying to ping a remote server from a PHP script in IE 6.0. When I load the page, the cmd.exe loads on the server and takes up all my CPU. I have to manually stop the process for it to go away.

My setup is this:
Windows 2003 Server
PHP 5.0.1

I have tried
- giving my system32cmd.exe full IUSR_%machinename% rights
- moved the cmd.exe to the script folder, to the PHP folder

And about a million other things that I can't remember =(. I have tried multiple functions, written in mulitple ways and the outcome is always the same. when the cmd.exe is opened it hangs on the 2003 server.

View Replies !
Use Exec() In PHP 5.2 On A Windows XP Pro System
I'm trying to use exec() in PHP 5.2 on a Windows XP Pro system. What I'm trying to do is use it to tell an already running program what to.

For example:
X:pathprogram.exe /something
or
X:pathprogram.exe /something_else

If I do the command through the command line, it works, but so far I have been unsuccessful in PHP. Usually it PHP just hangs, and give no error message, and does nothing to the program.

View Replies !
Exec Is Not Working Right
I'm trying to convert a video with exec i have just installed php 5.0.5 on my server and every thing seems to work except exec can you help
i have tried

<?
runExternal( "ffmpeg -i video.mov -s 320x240 -r 30 video.flv", &$code );
if( $code ) echo "bad transcoding";
else echo "looks good";

function runExternal( $cmd, &$code ) {

$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);

$pipes= array();
$process = proc_open($cmd, $descriptorspec, $pipes);

$output= "";

if (!is_resource($process)) return false;

#close child's input imidiately
fclose($pipes[0]);

stream_set_blocking($pipes,false);
stream_set_blocking($pipes[2],false);

$todo= array($pipes[1],$pipes[2]);

while( true ) {
$read= array();
if(!feof($pipes[1]) ) $read[]= $pipes[1];
if(!feof($pipes[2]) ) $read[]= $pipes[2];

if (!$read) break;

$ready= stream_select($read, $write=NULL, $ex= NULL, 2);

if ($ready === false) {
break; #should never happen - something died
}

foreach ($read as $r) {
$s= fread($r,1024);
$output.= $s;
}
}

fclose($pipes[1]);
fclose($pipes[2]);

$code= proc_close($process);

return $output;
}
?>
and
<?
exec("ffmpeg -i video.mov -s 320x240 -r 30 video.flv");
?>
and
<?
system("ffmpeg -i video.mov -s 320x240 -r 30 video.flv");
?>

None worked ....

View Replies !
Problem Using System/exec Function.
I am faced with strange problem. Basically I want to make a script which would take mysql back up for me. I have come up with following. [ basically code is borrowed from some other place ]
PHP Code:

View Replies !
Using System/exec, How To Backup Database?
system("mysqldump --opt myDatabase > backup.sql");

here are my problems,

i don't think it works on the webserver. next, where exactly the file, backup.sql be place if it does succeed.

i believe we just can't execute commands on the webserver can we?

i also tried using the sql query BACKUP TABLE ... TO .. but i'm guessing the problem lies with the TO... how do i know what directory shall i place it therE?

for instance, my pages are placed in,

home/myname/public_html/...

i tried to put
home/myname/public_html/backup in the TO but nothing happens.

View Replies !
Exec(), System(), Shell_exec(), Etc + Nmap
i'm trying to create a script that executes nmap from my server, then displays the output.

i've tried:

$output = passthru('nmap -v -A'.' $ip');
$output = shell_exec('nmap -v -A'.' $ip');
system('nmap -v -A'.' $ip');

the problem i'm having is that using the above methods i only get the first line of output, ie.

Starting Nmap 4.20 ( http://insecure.org ) at 2007-08-31 21:46 CST

and nothing else. i've managed to find a way around it by sending the nmap output to a textfile, the using file_get_contents() to pull the data back in:

exec('nmap -v -A '.$ip.' > /usr/local/www/apache22/data/nmap/'.$ip.'.html');    
$file = "/usr/local/www/apache22/data/nmap/$ip.html";
$result = file_get_contents($file);
echo "(pre)$result(/pre)";

that works perfectly, but i'd rather not be writing anything to the drive. i guess the problem might be that nmap takes about 5-10 seconds to do its scan, and for some reason php doesn't want to wait that long, i really have no idea. can it be made to work without needing to write to files?

and for the curious minds, i'm not doing anything dodgy, i just wanted an online tool i could access from any computer to test networks i support .

View Replies !
Command Window - Exec/system
I'm in the process of developing a script in Windows where I need to use exec/system. Whenever I execute either, Windows spawns a command window which automatically sappears. Is there a clean way to force Windows to NOT display the command window?

I've seen this discussed a few times previously, but, none of the
solutions seem to be working (tried both exec and system; tried using
cmd /c, tried using start /B, etc.)



View Replies !
Php Exec() Function Is Not Working
I am trying to execute linux command with php. I am try to log on as super user, so I have used the following code:

exec("su root");
exec("<password>");

But I dont think its working, becuase if I want to change my directory and view the list, I find myself in the same directory.
I have used the following code:

exec("cd /");
Passthru("ls -l");

View Replies !
Exec Stopped Working?
I wonder if anyone has experienced something like this, as it seems
truly bizarre and is causing me to tear out my hair (what little there
is left of it)....

The exec() function just suddenly stopped working, for no discernable
reason. Here is the code:

View Replies !
Exec And System Commands Blocked By Host
I've got this code, its the simpliest example I could make. It works perfectly on my windows xp/apache/php box, but doesn't do anything on a commercial website host. The actual code should use gzip to compress a folder but that doesn't work either.

Anyone know the reason why they would be blocking these commands? I suspect the problems with commonly used php apps like phpBB to be the real reason.

<?
exec("ping 127.0.0.1 > test.txt") or die();
// get contents of a file into a string
$filename = "test.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));

fclose ($fd);

echo $contents;

?>

View Replies !
Alternates To System() And Exec() In Order To Use ImageMagik?
My Web host apepars to not allow exec() and system(), as a line in my script:

system("convert -scale 100x100 $uploadfile $toimage");

gives the error:

"Warning: system() has been disabled for security reasons"

Is there some other way to use ImageMagik (or is it GhostScript?)'s
"convert" command in PHP that may be safer and generally allowed by Web
hosts?

View Replies !
Exec - Create An Executable That Return The System Drives
I need some help about exec command. I have create an executable that return the System Drives. It is based on DOS and does not need any parameter.

I have create my php script that executes the executable i've create and the source code is the following: ...

View Replies !
Running An .exe File Using Exec() Or System(), Unable To Fork Error
I have a problem with running an .exe file using exec() or system() I have downloaded a file called ffmpeg.exe for converting movie clips. I can use the program thourg the command line in windows (cmd), but I'm not able to have PHP run the file. First PHP gave be an "unable to fork" error. But then I gave users access to the cmd.exe file and solved that problem. So now is no problem running for example exec("dir");

View Replies !
Browser Sniffers Detection Not Working?
I have a couple methods at attempting to detect strings in UAs. Not working to well though. Any suggestions?

MSIE Attempt:

<?php $ua = $_SERVER['HTTP_USER_AGENT'];
if ((stristr($ua, "MSIE") ¦¦ stristr($ua, "Internet Explorer"))); {echo 'IE Detected' }?>

Gecko Attempt:

<?php if (!(strpos($HTTP_USER_AGENT,'Gecko') == true)) { echo("Gecko yes");}?>

View Replies !
Working On Browser Based Game But...
I am trying to make a game but I am having trouble with the frickin armory2.php everything else pretty much work but I am having trouble with the part that tells how much the power of the weapons to units are...

I am using for loops to do it but I am not sure why the outer loop gets nulled by the inner loop... Code:

View Replies !
Cookie Not Working When New Browser Is Opened
Okay, so if the purpose of a cookie "expiration date" is to make it remain on the user's computer for a preset time, why does it expire when I open a new browser? Code:

View Replies !
Redirect Code Not Working For Firefox Browser.
The following code works fine for Internet Explorer but not working in
Firefox Mojilla browser.

<form id="frmRedirect" action="www.something.com" name="frmRedirect">
</form>
<script language="javascript">
this.frmRedirect.submit();
</script>

View Replies !
Refreshing Browser Data - Cache Controls Not Working
I have a page that needs to refresh one part every time the page is visited. This part is controlled by

include "refreshme.php";

However, the data only refreshes when the browser's refresh button is physically pressed. I have included the following headers at the top of the source page.

header("Expires: Thu, 1 Sep 2007 07:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header("Pragma: no-cache");

Still no luck. Any idea on how to do this? I accomplish image refreshing by attaching a random number to the file. Example:

<?php $rand=rand(100000,999999); $rand="?".$rand;?>
<img src="<?php echo $picture.$rand;?>">

I cannot get something similar to work on the included php file.

View Replies !
PHP Functions Not Working In My System
Even the normal parameter posting for a php page through submit page is not running in my system.it says "variable not found".A normal php page runs. Should i include any php dll files for this?

View Replies !
Log Out - Page Expired Not Working Or Pressing Browser Back Button
I am a problem with I logout from my site. When I push log out link I send it to a new page with this script in this:

<?php
session_start();
session_unregister($SESSION);
session_destroy();
unset($SESSION);?>

In each page I have this other script
#accesscontrol.php
<?
session_start();
if (session_is_registered("SESSION")!= FALSE ) # ya la sesion existe entonces la cargo
{ #Maybe I use after. } else
{echo "<h1>Sorry...</h1>";
echo "<A href = "index.php"><H4> Login Univernet</H4> </A>";
session_destroy();
exit;}?>

The problem is when I log out and press the back button I am back to the pages. Sometimes it tells me that page expired but if I reload the page everything is ok and all my "security" pages are available.

View Replies !
System() Function Is Not Working In Windows
I want to encrypt a text file's content using public key of other user. I'm working in windows NT and running my php in apache server. I've installed my gnupg in c:gnupg.
To encrypt the content I used the following code: PHP Code:

View Replies !
Can't Get Phpinfo Working On My Linux System
I can't et phpinfo working for some reason on my linux system. every other php file works and every other command file works, but if i add the phpinfo() comand to the file then i get a forbidden 403 error??

View Replies !
System(); Not Working Within A Made Function
for some reason system(); isnt working when i use it within a function i made, is there a reason? it works perfectly fine out of the function.

View Replies !
Working On A Username Validating System
i am a working on a username validating system...and it needs to do the following things...

Only allow lowercase letters
Allow numbers
Allow "_" and "$"

and not allow anything else...and if it does not go by this print an error out.

View Replies !
System(), Exec(), Shell_exec(), But "Permission Denied"
I want to execute the php script via web server to run linux command. I try to use system(), exec(), shell_exec(), but the system show me "Permission Denied". i have set the file permission by using chmod 777 file.php .

View Replies !
Warning: Ftp_exec() [function.ftp-exec]: SITE EXEC Is An Unknown Extension
This is kind of a part II to a question a posted earlier about exec and shell_exec not working.

I'm trying to use ftp_exec to execute some simple command:

$conn_id = ftp_connect("$server") or die ("Cannot initiate connection to host");
ftp_login($conn_id, "$username", "$userpass") or die("Cannot login");
$command = 'cd..'
if (ftp_exec($conn_id, $command)) {
   echo "$command executed successfully";
} else {
   echo "could not execute $command";
}
ftp_close($conn_id);


I'm getting the following error:

Warning: ftp_exec() [function.ftp-exec]: SITE EXEC is an unknown extension in /home/urieilam/public_html/work/video/test1.1.php on line 21
could not execute cd..

Have tried other commands as well, get the same. Could this be a security issue or something to do with p Safe Mode? I don't know much about commands, shell, etc..

View Replies !
Warning: Exec() [function.exec]:
I'm using PHP Version 5.0.4 in IIS5, Window 2003. When I execute my script, it prompt me the following error :

Warning: exec() [function.exec]: Unable to fork [ping 10.8.1.70] in c:Inetpubwwwrootswitch.php on line 62
Below is my script :

<?php
$line1 = exec("ping 10.8.1.70", $output);
exit;
?>

View Replies !
How To Determine If The Browser Is An English Browser
need to seperated english traffic from the rest of it. What is the easiest way to do this? get_brower() seems pretty complicated, and from what i here sucks pretty bad!

View Replies !
File_get_contents - Making A Browser Within Browser
im making a browser within browser (dont bother asking why), but the problem is when i use file_get_contents, it works, however, the original HTML doesnt use absolute locations of images etc... so it tries to look for them on my server .

I tried using str_replace to change it but i cant distinguish between things which are relative and absolute references...

View Replies !
Make A News System With A Template System
i'm a total,and mean total newbie in PHP. I want to make a news system with a template system(like footer.php and header.php) but dont know how to?

View Replies !
Login System - News System
i have to do a news system wich use php/mysql.

i need 3 accounts:

* a 'reader' who doesn't need to log in to read the news
* a 'writer' who can write news in a pending news table
* a 'moderator' which validate a pending news, and make it a regular news,
viewable from the site (by the 'reader')

This is a small web site, so i can't use SSL; and i use php sessions.

Right now, i deal with account from a mysql users point of view, which
means, that a 'reader' can access all the admin part of the site, but will
ger errors when trying to read/write by sql query.

I was wondering if somedody could give me a trick to deny access to the
admin pages. Rigth now, i though about these:

* by decoding mydql rights? (how)
* by doing only-to-test query? (bad i think, especially for write right)

View Replies !
Working Connection... Not Working? (Advanced)
It has tons of modules, and obviously a config file which opens the db connection. But there is one, and only one, module having strange troubles.

$query is just a simple INSERT INTO command. But it does not inserts anything. I only obtain... nothing. Neither an error from the server! Code:

View Replies !
Need Help With Exec()
On Redhat linux, the command "passwd user" is interactive, so how can I pass data to and from the command with system() or exec()?

View Replies !
Exec();
well i know that exec("ndc reload"); would perform that command.. but i want too print out on the page what the command tells when i do like this:
[root@xermin cryzeck]# ndc reload
Reload initiated.
[root@xermin cryzeck]#

i want to print that Reload initiated. on the page.. how? not just echo("reload initiated"); but the stuff the command tells.

View Replies !
Using Exec()
I'm trying to use the exec() function to call shell scripts that in turn startup various programs under linux.. for example, when someone clicks on a link to restart a particular daemon, the daemon will then simply executed, either through the standalone command of /location/daemon or through the calling of a shell script that essentially performs an identical task.

My problem is that exec() seems to only work through the user "nobody," which the Apache web server is running under. The scripts and programs I'd like to execute are under a user account named "admin."

I've even tried chmod'ing all pertinent files w/ permissions that "nobody" could use to successfully access all necessary commands, without success, as the programs seem to crash whenever I do this.

View Replies !
PHP And Exec(dir)
I have been using opendir and scandir, but I want to try something
else.
Idea: using dir, and a) getting the result b) saving it as a file.

As I have problems with executing files directly, it create a bat file
and executes that.
I can execute command, but by some reason I dont get any response (it
should return something, and I get "")
The missing response is why I create a file.

I create the file on the network ( serversomewhere ) like this

dir "serversomewherefilesdir" >"serversomewhere
esult.txt"

Here is the odd thing: dir cannot read from the network - the bat file
is created there, it creates the result.txt file, but emtpy as it
cannot read from the network. Reading from c: and it works.

View Replies !
Php Exec();
i've been trying to create a php script that writes some text to a
file, then runs the perl interpreter on the file and shows the output.
it works ok when valid perl is written to the file, so if i use 'print
"hello world";' then it outputs 'hello world'. the problem is, if i
enter invalid perl code, such as 'blahblahblah;', it outputs nothing.
i'd like the php script to be able to get the error/output. does anyone
know of a way to do this?

View Replies !
Exec(); & Php As CGI...
I have had to do some work on a RAQ server with php as cgi. The script I have written uses the exec(); function to run pgp to encrypt a file. Weird thing is this:

The script does everything it's supposed to but I get the RAQ internal server error message. Should I be using passthru of something else in this environment? Forgive me I am a relative virgin as far as RAQs and php as cgi goes.

View Replies !
Exec Php
I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the application freezes. The following happens:...

View Replies !
Exec()
I am making a simple php script using exec() to execute commands in my linux host. When i execute 'ls' it shows the right content on that directory, but what i want to know if there is a way i can distinguish between folders and files. In this way i can lets say make folders show in black and files in grey. Also when i execute a wrong command i wanna get any system error message. Code:

View Replies !
Exec A .exe
I want to exec dos then within dos exec another.exe
then write to that program with database varables or session's but how?

how do you write to the last.exe program to give it it's command?

<?php
exec("C:/WINDOWS/system32/cmd.exe/program.exe");
?>

View Replies !
Use Of The Exec()
<?php
f($_POST['startup']){
if(!$online){
//$A1 = array();
//exec($servpath."khyller-server.exe") or die("<BR>Server Startup MSG - <Font color=red>Cannot find Server</font>");
//proc_open("call C:Serverlanked
eleasekhyller-server.exe", $A1,$A2,$A3);
}
}
?>

I'm first trying to get them to work at all just do something first. but with no success. I even sued or die and all I get is die D: Is it impossible or am I just dumb? I know I did this one, But I don't know how. Edit to add php color. my eyes were hurting in blackness.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved