Shell_exec Using System Tools - Wait For Process To Finish

Aug 14, 2005

I have a problem that hopefuly someone here knows the answer to. I want to do a shell_exec command from PHP.

I then want to continue with the script when the shell program is finished with what it does. Problem here is, that will take approximately one hour. How do I make the script wait until the program that I call in shell_exec is finished?

View 1 Replies


Parent Process Wait For Its Child To Finish Executing?

I have the most basic script:

$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
echo "parent done";
pcntl_wait($status); //Protect against Zombie children
echo "all done";
} else {
// we are the child
echo "Child finished";

When I run this, the output is always "Child finished". I'm running this on a lighttpd server.

View 1 Replies

Wait Until Iframe Finish Loading, Then Resume Code

I have a code where I need to use an IFRAME to load something from external page then display that the process has succeeded, then a message shows that user can close the browser. Now I'm using sleep() to delay the page (and hope that the IFRAME will finish loading within that time). But I dont think this is working as different people have different connection speed. Code:

View 1 Replies

Finish Http Response And Do Further Process?

In my case I need to echo a flag to client side and send an email .

Now client side needs to wait until the email is sent...

But I want to separate these two steps,how to do that?

View 4 Replies

Run Script From Another Script And Wait For Finish?

I need to call a script called build_report.php, pass in a URL variable named partno and wait until it is finished before continuing.

This script builds a report and then an email is sent out to our customer so I don't want the email sent until the report is generated.

Which should I use exec or cURL?

View 1 Replies

Why Shell_exec Executing More Than 1 Process

I dont understand why there is more than 1 process when I run run.php once from a browser

In the PHP code, I have the following:

shell_exec("php theprocess.php > /dev/null 2>&1 &");


I execute run.php from the browser [URL] Then I typed: ps aux | grep php

username@ [~]# ps aux | grep php
username 27272 0.0 1.5 89504 64468 ? R 17:33 0:00 php theprocess.php
username 27274 0.0 1.2 89504 49872 ? R 17:33 0:00 php theprocess.php


I dont understand why is it showing more than 1 theprocess.php process? Also why it still running at the background? it should terminate theprocess.php finish the task.

View 7 Replies

Shell_exec Executing More Than 1 Process?

I dont understand why there is more than 1 process when I run run.php once from a browserIn the PHP code, I have the following:run.php

shell_exec("php theprocess.php > /dev/null 2>&1 &");

View 1 Replies

Open A Command Line Process, Wait, Then Close It After Output?

Basically, and end user views my page, in doing this, PHP on my server will have to run a command line app and display the output in the browser.

This is really simple just by using shell_exec($cmd) where $cmd is something that creates some output.

The problem I'm having is that the program I execute from command line, stays open. This forces a deadlock in php until the process is closed, since it doesn't close itself after the output. Code:

View 5 Replies

Find A Process ID From Its Path Using Shell_exec?

I need to provide my users with a way to stop their cron task so that it can restart on its 5 minute cycle.

I think I need to use shell_exec to get the processes back and then kill the specific process. The only way I will be able to distinguish this process from the others running on the server are the paths i.e php /home/sconmod/public_html/**URN**/Includes/System/CronTask.php.

Does anyone know a way I can get the process ID of a process by matching the path?

View 1 Replies

Shell_exec Background Process *Windows*

I am trying to get a shell_exec command to run in the background. So far I have tried:

$ret = shell_exec($ffmpegcmd1." >NUL 2>&1");$ret = shell_exec($ffmpegcmd1." >NUL 2>&1 &");$ret = shell_exec($ffmpegcmd1." >NUL");

without any luck.

View 5 Replies

Shell_exec() Can I Run 2+ Of The Same Process On A Linux Machine?

using shell_exec() can I run 2+ of the same process on a linux machine?

Currently I have this:
$newPort = newPort();

View 5 Replies

System() And Shell_exec() Methods?

I am working with a WAMP installation (on Windows).Do the methods system() and shell_exec() only work on Linux machine or are they available on Windows, too? I am trying these methods in Windows but nothing is working.

View 3 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 ( ) 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 1 Replies

Validator For Seo Tools Within Content Managment System?

First thing:I know that there is interface to W3C validator.


But I don't know if I can install it on cheap hosting server.need validator for my seo tools within my Content Managment System so it must be pretty much portable.I would love to use W3C but only if it would be portable.I can also use Curl for this but it won't be elegant solution.


Is there any validator comparable to W3C but portable(only PHP that does not depend on custom packages)?

View 2 Replies

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 2 Replies

Shell - Run Multiple Commands In System, Exec Or Shell_exec?

I'm trying to run shell command like this from php:ls -a | grep mydirBut php only uses the first command. Is there any way to force php to pass the whole string to the shell?

View 3 Replies

Shellexecute - Command Is Not Running From Script Using Shell_exec() Or System() Or Exec() Functions?

I am working on Windows server and able to run command from command prompt

c:> %convertxls% {some args....}

But when I run same command from php script

*shell_exec(%convertxls% ..... 2>&1);*

it gives me error as%convertxls% is not recognized as an internal or external command, operable program or batch file.I think when I am running command from command prompt, it run for user which logged in. And when I run the php script it run for "www" user for which path is not set.Can anybody tell me where I am doing mistake?

*Note: I haven't written complete command.

View 3 Replies

Multithreading - Shell_exec - Access The Data From Process.php With Argsv[1] And Argsv[2]

there are multiple specific examples but I just wanted to have a working generic calling PHP into background example from shell_exec. So my php function runs a large processing job. On the top of the script (process.php) I put?


i think - any way to get that specific path, maybe 'which php'? then the actual command is

shell_exec(sprintf('php process.php %s %s > /dev/null 2>/dev/null &','data1','data2'));

and access the data from process.php with argsv[1] and argsv[2]?

View 1 Replies

Wait $x Seconds, Or Wait Until The "exec" Command Is Finished?

I'm working on a script that will dump a MySQL database to a file with exec(mysqldump [args]), then will let the user download the database.

The dump may take a few seconds, so I want to user to be forced to wait before downloading the file.

How can I tell my script to wait $x seconds before performing the next step in the script?
Even better, would be the ability to wait until the dump is done. Is this possible with PHP?

View 2 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 7 Replies

Offline Credit Card Process System?

what is offline credit card process system ? How to implement this in php ?

View 1 Replies

Server Unable To Process Request --->System?

Access webservices using PHP's soap.

Here's my code:<?php
test connection to agwebservice


Fatal error:Uncaught SoapFault exception:soap:Server]System.Web.Services.Protocols.SoapException:Server was unable to process request --->System.NullReferenceException:Object reference not set to an instance of an AgemniLogin.agLogin(String dn, String username, String password)---End of inner exception stack trace---in C:XAMPPxampphtdocsagsyncsyncwork.php:12 Stack trace:#0[internal function]:SoapClient->__call('aglogin', Array) # 1.C:XAMPPxampphtdocsagsyncsyncwork.php(12):SoapClient->aglogin('myDN', 'myUserName', 'myPassword') #2{main}thrown in htdocsagsyncsyncwork.php on line 12.Not sure if you'll need more info on the SOAP services.

View 4 Replies

Using The System Command With An Ampersand At The End Isn't Running The Process In The Background

I'm making a simple call to restore a mysql backup that takes about 45 minutes to complete on one of my servers.

system("mysql -u$user -p$pass $db < '$file' &");

Running it that way locks my browser and I have to wait until it's finished before I can do anything. This works fine on my other server. What settings could be preventing that from working on the first server?

View 1 Replies

Decide If A Failed System Process Like A Database Query Or Automated Email Merits An Error Message To The User?

I'm thinking through all the points in my PHP application where it performs some sort of system process like database queries, or sending out an email, and I'm wondering if at all these points I should be notifying a user when something goes wrong. There are so many points where an application can fall apart, that I'm having trouble determining if it is worth it to notify the user. Is it better to have some sort of logging in place, where every few days I just monitor the logs? Is there a standard approach for large-scale applications?

View 3 Replies

How To Finish Up Scripting Of Website

Hi! I am new to the world of coding, but am slowly learning. I am working on an internet scavenger hunt- so people search for a hidden icon on different sites all over the net. they are given a list of links to the sites participating and a riddle to help them find the right page on the site.

What I need: I need to code the icons so when clicked the user is returned to my site and it logs that that icon has been found. This is the main thing I need to get done. If it is possible I would also like to be able to give the users the option of saving their favorite sites maybe with a comment or adding a note option... and it would be nice if I could also show the sponsors how many people have found their icon.

I have it set up with registration and logins already... how do I go about finishing this project?

View 3 Replies

Long Time To Finish A Program

I have a perl program called by my php script, which in turn is called
by the browser. Now, the perl program is called using exec, but takes
a long time to finish. So, till the time the perl script does not
finish its job, the browser does not show anything. I have messages
like "Dont close this window", but that does not show up till the
whole perl program finishes. Is there a way, I can somehow remedy
this, try to show a message on the browser - "Please while your data
processes" and then do the processing in the background?

View 2 Replies

Copyrights 2005-15, All rights reserved