Shell_exec Using System Tools - Wait For Process To Finish

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?


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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

Offline Credit Card Process System?

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

View 1 Replies View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

Code Doesn't Finish In 3 Seconds

I'm trying to execute a portion of code within a specific number of seconds. If it fails, I need to break out and do something else. To give you an idea of what I mean, take a look at the pseudo code below:

try to complete the code below for 3 seconds { do something that could take a long time. if it doesn't complete within 3 seconds, generate an error which will abort the processing of further instructions in this try } catch (Exception $e) { Execute some different commands since the code above didn't finish quickly enough.}

View 1 Replies View Related

360 Grid -- Finish Out Row With Odd Number Of Records?

I'm trying to accomplish this, with the 360 grid system: [URL] From a database i'm getting products which will be displayed in lines with 4 on each.It's working perfectly if there is exactly 4 products under each category, but if there is less than 4 products in a category, the design is messed up, because the div's not closed properly.Problem is that sometimes there's only 3 or less products on a line.

for($i=0 ; $i<$countprod ; $i++){
$prevprod = $products[$i-1]['name'];
$curprod = $products[$i]['name'];


View 3 Replies View Related

Automation - Schedule Script On Job Finish (from CLI)

I am processing a big .gz file using PHP (transfering data from gz to mysql) it takes about 10 minutes per .gz file. I have a lot of .gz file to be processed. After PHP is finished with one file I have to manually change the PHP script to select another .gz file and then run the script again manually. I want it to be automatically run the next job to process the next file. the gz file is named as 1, 2 ,3, 4, 5 ... I can simply make a loop to be something like this ( process file 1 - 5):

for ($i = 1 ; $i >= 5; $i++)
$file = gzfile($i.'.gz')
...gz content processing...

However, since the gz file is really big, I cannot do that, because if I use this loop, PHP will run multiple big gz files as single script job. (takes a lot of memory) What I want to do is after PHP is finished with one job I want a new job to process the next file. maybe its going to be something like this:

$file = gzfile($_GET['filename'].'.gz')
...gz content processing...

View 3 Replies View Related

Let Script Finish Even Users Close Their Browser

I am using Linux, php and mysql.

When I run my script, it will take a very long time. So when users
close their browsers, my scripts stop either. What I want to do is let
the script continue running and send an email at the end.

How can I successfully do that?

View 3 Replies View Related

Allowing User To Return And Finish Survey Later

I am writing a web-based survey and would like to allow users to log off and return later to finish the survey. I believe that I should use cookies but have no idea how to go about it.

How can I allow users to return to a survey at a later point in time without losing their data from the previous visit (on the same form). (The survey will have multiple pages.)

View 1 Replies View Related

Detect Form Submission Finish With Jquery?

As we know you cannot create a file download via ajax.

you can however submit a form which will create a download prompt.

I am generating quite a big file when the users presses a button so I display a "please wait" style message.

My question is,

How can I detect when the form submission has finished, hence the dialog box has been shown?

(this is to hide the message)

View 2 Replies View Related

Nohup On Windows - Exec Without Waiting For Finish?

Is there something like that for windows ?

exec("nohup /usr/bin/php -f sleep.php > /dev/null 2>&1 &");

View 3 Replies View Related

Execute Another File Without Waiting For It To Finish Its Execution?

I have StartServer.php file that basically starts a server if it is not already started. Everything works perfect except that the StartServer.php will hang forever waiting for the shell_exec()'d file Server.php to finish its execution that it never does.

Is there a way to execute a PHP file and just forget about it -- and not wait for its execution to finish?

Edit: It has to work on Windows and Linux.

View 3 Replies View Related

Finish By Using The Fclose(handle) Function After Writing To A File?

Why do I need to finish by using the fclose($handle) function after writing to a file using php? Doesn't the program automatically do this when it ends?

View 6 Replies View Related

Using Sessions To Pass Vars From My Form.php->verify.php->paypal->finish.php->mailer.php.

I'm using sessions to pass vars from my form.php->verify.php->paypal->finish.php->mailer.php. I think I'm mixing versions of php sessions...dunno. The host I'm using has v4.2.2 with sessions enabled and the $HTTP_POST_VARS works well posted directly from form.php...but I think is messing me up in the mailer.php. I've tracked the session_id() all the way thru but the vars are not being passed into the final mailer.php. Fix? Code:

View 10 Replies View Related

Load An Ajax (jquery) Request Response Progressively Without Waiting For It To Finish?

I want to make a form that will use jquery to submit a list of keyword to a php file, this file could take a lot of time to load depending on the size of the keywords list.

What I want to do is to load the php response into a div or container in real time without using iframes.

All the ajax request I know have to wait until the request has finished before having access to the response, I need to get access to that response even when it hasn't finished so I can update the progress in real time.

View 4 Replies View Related

Script Which Takes A Long Time To Finish And It Fails Due To Execution Timeout?

I have a php script which takes a long time to finish and it fails due to execution timeout (script runs too long) or network timeout.Essentially the script does a for loop which does two to three processes on each iteration.

request an external service through curl
parse the xml
insert the response into a database

Suppose that each iteration takes 1-2 seconds to complete.To resolve the timeout issues I tried to set max_execution_timeout and default_socket_timeout to 0. Please let me know if this is correct.The key point to note is that the for loop may process 70,000 records -- it's basically a bulk SMS system.I've tried sending partial responses to the browser using flush() or ob_implicit_flush(true) and setting utput_buffering to 0 but I'm only getting the final response and not the partial ones.

View 2 Replies View Related

Start Process In Background Then Kill Process?

start a process from php in the background so I can kill it later in the script. Right now, I'm using: shell_exec($Command); The problem with this is it waits for the program to close. I want something that will have the same effect as nohup when I execute the shell command. This will allow me to run the process in the background, so that later in the script it can be closed. I need to close it because this script will run on a regular basis and the program can't be open when this runs. I've thought of generating a .bat file to run the command in the background, but even then, how do I kill the process later?

The code I've seen for linux is:

$PID = shell_exec("nohup $Command > /dev/null & echo $!");
// Later on to kill it
exec("kill -KILL $PID");

View 2 Replies View Related

Multithreading - Process Forking And Get The Child Process Id

Objective: My script will download a remote file upon form submission, since the file might be big, I would like to fork off a process and let the user go on with his/her life.

Example of a command:

wget -q --limit-rate=1k --tries=10 "" -O /web/assets/content/image/image_euv_press.jpg

Method tried:

pcntl forking,
$pid = pcntl_fork();
if ( $pid == -1 ) {
} else if ( $pid ) {


Question: the background process method works but it's not clean, is there a better way to fork off a process to download and get that wget command PID so I can kill it later?.

I have tried echoing $! after doing the exec just to get the PID but exec('echo $!') doesnt return anything, i think it's because every exec is a different "space"

I added '> /dev/null 2>/dev/null &' to the end of the command on my terminal it would return something like: [3] 30751, but through php exec, there is no way to capture that returned PID.

View 3 Replies View Related

Copyrights 2005-15, All rights reserved