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.





EXEC() Runs Process In Background


Exec, shell_exec, system, popen functions all run the process in the
background.
how can i get it to run the process normally.
my code looks like this:
<?
exec("batch_file.bat");
?>

am i doing anything wrong?




View Complete Forum Thread with Replies

Related Forum Messages:
Exec Background Process
I want have PHP call another process (another PHP script at the moment
but it may end up being a binary) in the background and not wait for
process to complete, but rather instantly jump the the next line of
code.

I've tried things like:

exec("./script.php &"); // script.php has executable permissions set
exec("at -f ./script.php now"); // and #!/usr/bin/php at the top of
the code

Neither seem to work. They both execute script.php, but both hang
around until script.php has completed.


View Replies !
XP Exec Background Process
I was trying to exec a background process on XP using PHP CLI, but could
not get it to work. Suppose the command I want to spawn off is "cmd".
On *nix, it is as easy as putting ampersand "&" at the end of the command.

I tried the following on XP without working.

exec("cmd");
exec("cmd >NUL");
exec("cmd /c cmd");
exec("start /b cmd");

I tried many combination, but on each one, PHP waits for cmd to exit
before continuing.

Doing this in Windows script host (cscript) is simple:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd", 0, False

The "False" parameter causes the Run method to continue immediately
without waiting for the command to finish. So I could make my PHP file
exec a VBS file that does the actual background execution of my command.

PHP exec documentation says it will not wait if output of the command is
redirected somewhere, but this didn't seem to work for me. If anyone
has experience in doing something like this on Windows XP SP2,

View Replies !
Run Process In Background
I want to run process from my php script in background.
I try different functions from functions list but all of them whaiting for
process ending. How can I run `wget -b ...` and finish my script, but wget must still working? I use PHP5, Linux, Apache2.

View Replies !
Background Process
I would like to create a script that acts like a background process. Basically once every hour, it will access a website, gather data from it, and write that data to a file on a remote server. The PHP code would be running on this same server. Is this type of non user activated, constantly running code possible?

View Replies !
Background Process/multithreading In PHP?
I use PHP for a user login application and it works fine. The problem is that another process should start up as soon as the user logs in and should keep on displaying different popup messages every 5 minutes. Is there a way I can implement this using PHP?
Basically the idea is to get a background process running, thats it.

View Replies !
Running PHP Process In Background
Here's the deal, I work on a PHP based menu system for my company. The menu system allows users to run reports, change settings on our Linux box, etc.

My problem here is with the reports. Some of them can take 10-15 minutes to run. That's a long time to force the user to sit and watch a "Loading..." screen. What I'd like to do is somehow send the report process to the background. Code:

View Replies !
Running A Background Process
I' m trying to run a php script in background using exec(). I have a browser request to eventtest.php, which contains:

<?php
exec("/usr/local/bin/php -q event1.php &");
die();
?>
====
event1.php has:
<?php
error_log("initiate event1", LOG_FILE);
die();
?>

the result is that the log entry is never generated if eventtest.php is requested, but works fine if event1.php is requested directly.

While eventtest.php is running, i see stuff like this from ps -aux, repeated many times. Any ideas what is going wrong? Is there a better way to initiate a background php process. I am running this on a shared hosting environment on Linux Code:

View 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 Replies !
Pass Variables To A Background Process.
I know how to start a process in the background, but how do I pass variables (from the calling script) to the background process?

View Replies !
Forking A PHP Process Into The Background In A Web Server Environment
I have installed the PCNTL functions[1] on my PHP enabled webserver
in the interest of being able to fork a process into the background so I
can do some heavy processing but return control of the browser back to the
user rather quickly.

However, after mucking about with PCNTL for a while and not getting the
results I expected, I finally stumbled across this line in the opening
parragraph on PCNTL functions on PHP.net:

"Process Control should not be enabled within a webserver environment and
unexpected results may happen if any Process Control functions are used
within a webserver environment."

Seems like they should bold and highlight in red that line, but I digress.

In any case, can anyone suggest a way to fork a process off to unload a
large amount of processing and return control of the web browser to the
user? All the examples and whatnot I have found assume a CLI version of
PHP. I want to do this on the web server!

[1]I am running Apache2/PHP4.3 on RHEL 4. I downloaded the RPM for PCNTL
at

View Replies !
Exec In Background On Windows
How can I get an /exec'ed/ process to run in the background on an XP box?

I have a monitor-like process which I am starting as
'exec("something.exe");' and, of course the exec function blocks until
something.exe terminates. Just what I /don't/ want. (Wouldn't an & be
nice here! Sigh)

I need something.exe to disconnect and run in the background while I
continue on with my script.

View Replies !
How To Start Script In The Background (using Exec())?
I have some troubles trying to start php script using exec() and leave
it running in the background.

Manual says: "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."

So, I'm doing this:
exec("/usr/local/bin/php /mydir/myscript.php >/dev/null 2>/dev/null
&");

I don't recieve any output from "child" script, but "parent" script
waits until "child" is doing its work.

View Replies !
Exec Command Executing The Program In The Background
i am running xampp on my computer from apachefriends.org, it's a apache server

this is the php script

<html>
<head>
<?php

exec ('notepad');
?>
</head>
</html>

but when i execute the php script on my computer , notepad doesnt not run

i used a process viewer and discovered that notepad is running in the background and i cannot see it

does anyone know how NOT to make it run in the background? i wan to see the notepad window on the apache server (my computer)

View Replies !
Security In An Process Started With Exec
The php script that processes user input from a form, starts a new process
using exec. In my case, the process may contain arbitrary, user defined
functionality. How do I ensure that that process doesn't do any harm? Is
there a way to define a sort of sandbox that the process can run in, so it
won't be able to access any unauthorized resources, or do some other damage
to the server?

I am running PHP 5.1.2 on Apache 2, on Win XP Pro.

Thanks,

A

View Replies !
Error Running Exec() To Kill A Process
Red Hat Linux 7.3, Apache 1.3, PHP 4.3.3 I am trying to create a PHP script to terminate a process that is running on the server. The file and folder permissions are set correctly, but I am getting the error "kill 943: Operation not permitted"; I am running the command "exec ("/bin/kill 943");".

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 !
User Runs PHP
I have an app that uses PDFLib to read some images off the file system (Red Hat linux) and puts them into a PDF. I have permissions set on the directory to be readable by the owner and the group, 'images'.

I made apache a member of the group 'images' but get a permission denied error when trying to read an image from the images directory. Is there some other user that owns the PHP app.

Env.
PHP 5.03
Red Hat ES4
Apache 2.02

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 !
PHP Only Runs From Command Line
I know very little about PHP, but I was just curious to know
why exactly would some PHP code run fine from the command line but not
from the browser?

I'm just curious. I was working with someone else's PHP code that
supposedly created MySQL tables in a database and for some reason it
just wouldn't create the tables at all (no specific error message).
Someone suggested I run from the command line and when I did, it
worked...

View Replies !
Cleaning Up After A Script Runs
how do you clear all varialbles and arrays after a script is run?

View Replies !
Bad Query Runs With No Error!
there must be some weird setting on the mysql database i am using for this latest project. the following query runs without throwing an error:

SELECT start_time, last_access_time, user_ip session_data FROM demo_sessions WHERE id='b31fd40c7e9135f2b52e4f17c23fc3c54da137b8'

notice there is no comma between user_ip and session_data

what's the story here? seems like a real security risk to me because my server won't log bad requests.

View Replies !
Why Script Runs Differently With CRON?
I am running a PHP Script that downloads my RSS News (and the accompanying Thumbnail images)from the Web. When I execute it from CMD line, no problem. The News and Images are downloaded, great!

When I begin to update via CRON, no images are downloaded/written to disk.--I don't have this problem when it's RUN from a shared hosting account, it's only on my home Linux Box.

View Replies !
Bug 23891 MySQL Runs Out Of Connections
http://bugs.php.net/bug.php?id=23891

According to this report, what the person was asking isn't a bug, it's
a feature (rimshot).

I'm running into this problem almost exactly, and really don't
understand what the answer is. The support person snidely suggests
reading the manual, which is always great advice, but in this case
really doesn't help out.

Could someone explain what "If you use mysql_select_db() or slightly
different connection string you can have more open connections then
you have process." means?

If I don't use mysql_select_db, then what do I use?

View Replies !
Close Window After Script Runs
When a user clicks on a link in their email, I have a browser window that opens in the background and runs a script confirming their desire to be added to our email directory. I basically want this window to open, run and then close without the user having to deal with it.

Is there a way in PHP to close the window after the script finishes running in it? Or should I revert to JavaScript? I want the script to be mobile so I've sort of ruled out processing it server side. TIA.

View Replies !
How Often Does Garbage Collector Runs In Sessions?
Does anybody knows how often the session garbage collector checks for expired session to delete them? is it possible to modify this timeframe? is it possible to call this function manually?

I am storing my sessions in a mysql database and i am using a session expiration of 5 seconds (just for testing), but after the session is expired the session record in the db table still exists.

and it looks the sessions aren't expiring either because if you still have the session cookie you can keep up with the session. Code:

View Replies !
Email Form Which Runs From An Iframe
I have set up an email form which runs from an iframe. The only problem is that when the script redirects the user to the success or error pages, these pages open within the iframe. Is there a way to specify the target window as 'parent'? Someone said that this could not be done via the php script and would have to be done with javascript in the html form itself.

View Replies !
Optimizing Query That Runs Slowly On Linux
I was wondering if anyone has any insight into why the query I have posted below runs exceedingly slow on my Linux server. I am using Php with a MySQL database. On both my development computers the query runs briskly. They are however both Windows boxes, one running Windows XP and the other running Windows 2000 Professional. Here is the culprit.....

View Replies !
Counter - Increased By One Everytime The Loop Runs
i want to make a counter that i can echo. its going to be used in a while loop so i want it to be increased by one everytime the loop runs so each time it runs it would look like this:

counter=1
counter=2
counter=3
etc.

View Replies !
Php Script Auto Runs At Specific Time?
Is it possible to have a php script automatically execute at a certain time without having to visit the page or manually executing the code?
For example, execute test.php every hour?

View Replies !
Switch Statement That Runs Through Cases Numbered 1-100:
I have a switch statement that runs through cases numbered 1-100:

What is the most optimal way to run this switch?

switch($a){

case 1:

case 2:

...
}

View Replies !
MySql Is Loaded When Runs From Command Line, But Not Through IIS
Sorry for the newbie question, but I've been searching and searching and
haven't found an answer to this one yet.

I installed PHP and MySql (both latest versions) yesterday on a machine
running Windows 2003 Server with IIS6. Code:

View Replies !
How Do I Create A Link That Runs A MySql Query When Pressed!!
I Want To Create A Link, And When You Press That Link It Runs A MySql Query.

View Replies !
Header Function Runs Before Update To Database Is Made
I have been having some problems with a part of my login script. This is the two lines of script I am having problems with:

mysql_query("UPDATE " . $userName. " SET login = '$loginIN' WHERE pass = '$password' AND course = '$courseID'");
header( 'url=http://www.somewebsite.com/logged_IN.htm' );

The problem is that when this php script is executed the second line executes before the first and an update to the database is not made. I also tried the script without the second line and the first works then.


View Replies !
Query Runs In Mysql But Returns Error 1064
The same query runs in mysql and in Zend interface but not runs when using inside php script. I am receiving the error:

"1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'str_qry_Insert' at line 1"

INSERT INTO fnd_script_type (type_name) VALUES ('test1')

I already have tried it with as:

INSERT INTO `fnd_script_type` (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (type_name) VALUES (`test1`)

what am i doing wrong ?

View Replies !
Query Runs Multiple Times Under Heavy Server Load.
I have been having an issue with some MYSQL queries running multiple times when the server is under a heavy load. 

Example, if I do an 'update Table1 set item1 = 0 where 1 = 1'

This runs fine under normal conditions, but will repeat itself multiple times when the server is under load.  Is this just an optimization or server resource issue.  If so, I would assume the query would just timeout and not run at all instead of running a few times.

View Replies !
POP Account Creation Script On CPanel. Runs Fine On Win2000, Not On Linux.
I am facing a weird problem. This is a POP account creation script. If I run it from my Win2000 PC, it creates the POP account. But when I run this script from the Linux server (CPanel is also on that server), it does not create any POP account.

View Replies !
Working With Dates - Runs And Queries The Database To Produce A List Of Information
I have a script that runs and queries the database to produce a list of information, based on a date range. This is to fllow up on a script that is automatically run each Sunday night.

What I want to try and acheive is, for example, if someone manually runs this report on a Tuesday the script will assume that it is run on the Sunday night, to make sure the results are exactly the same as the emails that have gone out. PHP Code:

View Replies !
"Please Wait" Page While Php Runs Mysql Queries
Does anyone have any idea what I should google to create a "splash page" that tells the user to wait while a few mysql quieries are run through the php page?  It takes anywhere from 5 to 20 seconds, and I don't need a progress meter, just a splash page so they do not go anywhere and the user doesn't think there is a problem with their browser or network connection.

View Replies !
In Background
Here's my situation. I'm creating a website (basically a store) and in the admin section users will want to download zip files of images or products added in the last 7 days, last 2 weeks and the last month.

I have scripted a cron to run every 24 hours to zip all the images and this process takes over 1 minute (there's over 6,000 images!!) and the size of this is 250MB. This has now taken me to my quota on my webspace of 500MB (including all the individual images)

I have decided the only way to do this is dynamically create the zip when the user requests it. As PHP times out after 30 seconds it needs to do it's stuff in the background and display a message saying something like' We'll email you with the zip file in 5 minutes or so'.

View Replies !
Run In The Background?
I have a script on my website that takes a long time to run, and it's slowing down my pages. Theres nothing I can do about the wait time on the file.

Is there a way to use include or fopen or anything along those lines, to have it execute my file in the background; without having the file that's executing it waiting for it to finish its thing? Or to have the expected output redirected to another file (as mentioned in http://ca3.php.net/manual/en/function.exec.php)?

View Replies !
Running Background Job...
Is it possible to get a php3 script to check what day it is, and then do some stuff, If it’s let’s say Monday?
This without you doing anything. Like a background - or cronjob…
I guess you would use perl or something to do this, but that is not an option I have.

View Replies !
Background Processing
What is the technique you use for background processing? Like when user submit a task, the user could then wait for the result by email or through a result page.

I'm wondering how would they do that?

View Replies !
Background Color
I am totally baffled by what is happening in my code. I have a section
of code (shown below with two comment lines inserted). They are
essentially identical text boxes (names and variables different). Yet,
the first comes up with a white background and the second comes up with
a yellow/gold background....

View Replies !
Background Processes
I'd like to know how to send an external process to the background, so that I can run multiple instances of the same process at one time. Any tips, links.. etc?

View Replies !
Php Running In The Background?
In order to run a php script - do I need to access it via a browser? Is there a way to write a php script and let it run from the shell in the background?

View Replies !
Running Php In The Background
I am trying to run a php executable (GTK) from a browser... now exec() does the job, but the browser hangs waiting for the .exe I have just called to finish, I assume so it can 'report back' to exec(),

any ideas how I can get around this ? - I have tried backticks,passthru,system,exec - all with the same results, i.e. they all expect a returned value and sit around waiting for it. This is a windows app so /dev/null wont help & it is not a CGI with output I can dump anyway.

View Replies !
Run A Php In The Background Using Http
i have a script (script1) which needs to call another script (script2).
It should not wait for the answer, so script2 should run in the background.

I really need to call the php script using:
http://urlof myscript/script2.php

I don't want to use it as a cgi and use CLI.

I did a test with fsockopen and curl and a timeout of 10 seconds and call
http://urlof myscript/script1.php from my browser:
Script1 stops after 10 seconds => OK
Script2 has been called by script1 and continue to run in the background
=>OK
After 60 seconds Script2 is killed by php!! => KO :(

The script is working fine if i call http://urlof myscript/script2.php from
my browser. It needs around 120 seconds to finish.

Why is it stopping after 60 seconds when I use fsockopen and call it from
script1?

Here is the script in SCRIPT1:
$fp = fsockopen("$host", 80, $errno, $errstr, 30);
stream_set_timeout($fp,10);
if (!$fp) {
echo "$errstr ($errno)<br />
";
} else {
$out = "GET $path HTTP/1.1
";
$out .= "Host: $host
";
$out .= "Connection: Close

";

fwrite($fp, $out);
$status = socket_get_status($fp);

while (!feof($fp) && !$status['timed_out']) {
echo fgets($fp, 128);
$status = socket_get_status($fp);
}
fclose($fp);
}

I have added this in SCRIPT2:
ignore_user_abort(FALSE); // becareful, FALSE really means it should ignore
user abort !!!
set_time_limit (120);
ini_set("max_input_time",120);
ini_set("max_execution_time",120);

Do you have any idea?

View Replies !
Background Refresh
I am using php_move_file to upload some files to the server. I want to
be able to support large files. But the Apache settings is that after
90 sec. the connections resets. This becomes a problem with large
files (slow links). Is there anyway to write a script that would
refresh in the background....

View Replies !
A Way To Get Current Background?
I have several websites running on a global script. Some pages, the backgrounds black, other, white. Sometimes people have the taste of posting black font on a black background, or white font on a white background.

What I wanted is to know if theres a way to 'check' the current background color? Because I can then add in the script to 'change' any incorrect colors before posting. I'm not sure if theres a way for PHP to tap into CSS and check, but it would be alot easier to change the global script since its *Checking* for the background color rather then me do it per site and change it manually.

View Replies !
Background Redirection
I need to create a redirection from a php page to another, without having a web browser opened.

Imagine that you make a php starting via command line or cron job, then your php is running in background and no web browser is open on it. How can this php (from the background, with no web browser opened) call (trigger) another php? please note that I'm not talking about include.

I need that the background php gives control to ANOTHER php url . per what I tested the php 'header' command does not work and obviously also any javascript redirection cannot work because there is no web browser opened. so, finally, how can that php running in background call another php url?

View Replies !
Using SWF Files As Background
Im not sure if it posilbe, but im trying to get a SWF file as the background of my page, but the swf file is dynamically named.  Its like a gallery and when a user clicks on the lick to that file, it displays the image /swf.  but i want the file to appear as the background. code:

echo "<body background = '".$POST['file_name']."'>";

ii have 3 files so far.  file1, 2, 3 .swf.  and i can easily view each one as a seperate file, and they work once i embed them as images. is this my php code, or do i have to look at my browser to display the swf as BG..?

View Replies !
Background Running
I have a php script. It basically fetches data from MySql DB, processes it, and updates the results back in the Database. There are some 18k rows in the DB. The processing involves querying some remote servers.

What is the MOST efficient method to run the script in background ?

View Replies !

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