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.





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 Complete Forum Thread with Replies

Related Forum Messages:
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?

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 !
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 !
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 !
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 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 !
Launching A Background Script From Php In Windows/IIS
I'm trying to build a PHP page which launches another php script to be run
in the background. The web page should return immediately, while the
background script may run for 10 minutes or something. Unfortunately I'm
getting all kinds of weird behaviour..

In my main script I'm using exec() (also tried the other options) to start a
..bat file. This actually works, the batch file is launched and is able to
write something to disk.. Now if I put the following line in the batch file:

c:phpphp.exe -q backgroundscript.php

then instantly I'm seeing about 30 php.exe processes being created, but
nothing seems to be happening really. The processes seem to be dying
immediately and replaced by new ones. So apparently php is trying something
but fails and tries again.

Both the script and the batch file work fine from the command line. Group
'Everyone' has read/execute rights for the batch file, the php script and
php.exe. I have tried prefixing the command with START /b or cmd.exe /c but
neither seem to make any difference. Also I tried redirecting stderr, stdout
and stdin to NUL

Server is Win2k, IIS5, php4.3.0. Searched the php docs, tried suggestions
but it doesn't work, maybe because they use Apache.

My guess is that the anonymous user IUSR_* doesn't have the rights to do
something, but I can't figure out what.

View Replies !
Want To Spawn Process From Windows PHP
I wanted to write some code purely on Linux, but unfortunately the
document scanner drivers are non-existent for the high-end commercial
document scanners. So, I had to port my Linux PHP project to Windows
PHP (WAMP). There, I found a scanning tool (Kodak Image Scan -
imgscan.ocx) that I can put on a VB form, tell it to scan some
documents into a TIF file, and then shut down.

I can run this VB app at command line just fine, but when I run it from
either a popen(), system(), or exec() call, it won't detach from the
PHP page. Instead, it just sits there. I can see the VB exe I made is
being loaded properly in RAM, but unfortunately it sticks and won't
unload on its own, nor will it tell the scanner to engage. I have to
kill the VB exe and then the PHP page continues.

What's the way to spawn a detached process from PHP on Windows?

View Replies !
Process Management In Windows
All I need to do is run a windows batch file from a small php program, and
return the windows process id of the batch file. I have played around with
proc_open() but that returns a resource id. Does anyone have a suggestion
on what call I could use to get the windows process id returned within my
program. I am using windows xp pro, and php 5/apache

View Replies !
Calling PHP From A Windows Process
I'm calling PHP from a windowsprocess in a simple Webserver application. I'm using the createprocess Windows API command....

C:PhpPHP Filename.php

In this file I will open a TCP/IP connection to my SQL-server. When I do so, I always get the following error
mysql_connect(): Can't create TCP/IP socket (10106)

No I start a command shell and I call the same...
C:PhpPHP Filename.php

This will work without any error!!

Same effect I get from all TCP/IP Actions (FTP etc....)

Can somebody help me. Is it a PHP Setting, a server variable or a WindowsXP Access right problem?

View Replies !
Possible To Check To See If Windows Process Is Running From PHP?
I need to check the state of a processes from within a PHP script on a
Windows machine. All I need to know is whether or not the process
exists (i.e., is running). Anyone have any ideas?

I searched the archives and found proc_open(), but if it can do what
I'm trying to do, I can't figure out how.

View Replies !
Creating Or Simulating A A Process Fork On Windows
IS there anyway of running two or more scripts seemingly simualtaneously?? PHP is installed on a Win 2K machine.

View Replies !
Shell_exec Help Please
I have an ensim server which provides me with about 20 scripts in the filesystem that allows you to create sites, edit them, lookup domains, etc... I am running a few of these scripts from a cron I made and that all works fine but I can't seem to find a function (like shell_exec) that allows me to get the text returned from the function. When I run the script from CLI and i run the script using either system(), exec(), passthru(), or shell_exec() it just displays the results, and I didn't tell it to, it just does it on it's own bit. My question is how can i trap the results so I can anylize them.

View Replies !
CLI And Shell_exec()
I am using Imagemagick and some other apps via command line calls (if I stated that correctly, hope so).I run a WinXP server, Sambar 5.3. I use this format for my typical call: PHP Code:

View Replies !
Ssh With Shell_exec
I'm trying to 'ssh' into another machine, run a small script and fetch
it's output, using shell_exec(). The problem is, it takes AGES to run
ssh and I don't know what's happening. If I try 'ssh'ing manually on the
shell, it takes a microsecond to fetch the result, whereas shell_exec
takes very very long and I don't know how to debug the problem. That's
problem number one: How do I tell what's happening and why is it taking
so long?

Problem two: To be able to establish a password-less ssh connection, I
generated a public key/private key pair for the two machines and stored
it in my /home/username/.ssh directory. Okay, I know apache/php (by the
way I'm running apache with PHP 4.2.3) won't know where to find it so I
presumed /opt/apache/.ssh would be the best place to copy the ".ssh"
directory (i.e. apache's installed in /opt/apache). Now the problem is,
I couldn't get shell_exec to run ssh in a password less mode. After a
little while I realized that it was looking for the private key in
"/.ssh" (i.e. the root directory)! How come? How do I change it so that
it looks for the .ssh directory elsewhere? (I mean, how can I run a
command using shell_exec and ask it to use the "home" directory of the
"apache" user, which normally is /path/to/apache)? The last time I
installed php & apache, I remember it looked for the .ssh directory in
the /opt/apache/.ssh directory and now it has changed. also, it was much
faster the last time. Now for some reason it's EXTREMELY slow (takes a
whole minute to run ssh) and looks for the .ssh directory on the root
(and I dont want to place that directory there).

View Replies !
SSL Through Shell_exec
I've looked at the php documentation for openSSL, but found that the module seemed insufficient for purposes like checking a certificate's expiration date on another server. That is, I could not find a function to run "openssl s_client -connect", so I decided to instead achieve it through shell_exec.
This is a three step process:

1) Check the openssl version via shell_exec('openssl version -v'); just to confirm that openssl is installed and runs properly.
This returns "OpenSSL 0.9.7a Feb 19 2003 "

2) Connect to the remote server. As a test, I decided to use www.gna.org, since I know they use a certificate. shell_exec('openssl s_client -connect www.gna.org:4433');

This pauses for about 20 seconds, and then returns FALSE. I've tried various combinations, like removing the -connect argument but leaving the server name in, removing the port, including the https:// part, removing the www, and so on. I have not tried a port other than 4433 yet (I wouldn't know what other part to use). All other methods returned FALSE immediately. This is the only method that delays 20 seconds, which indicates to me that I'm close.

3) Fetch certificate expiration date via shell_exec('openssl x509 -enddate'); although this obviously returns FALSE because I have not been able to connect to the server yet.

View Replies !
Cd With Shell_exec
I have the following script:

$c_path = "/absolute_path_to_some_directory";
$test_cmd = "cd $c_path; ls";
$test_res = shell_exec($test_cmd);

it always lists the contents of the directory where it is placed, rather than the contents of some_directory. In other words, it appears that cd is not working. I have verified that path and permissions are correct. PHP is version 4.3.9.

View Replies !
Shell_exec
I want to copy file from remote machine to local machine using PHP. On both machines Linux operating system present. The code is.

$result=shell_exec("scp admin@192.168.1.236:/mnt/disc/hda/part1/demo/
conn /opt/lampp/htdocs/upload/");

View Replies !
Basic Shell_exec
I am trying to use shell_exec to do some scheduled clearing up but can't get it working.
PHP Code:

View Replies !
Exec Or Shell_exec
I am trying to us shell_exec and keep getting an error. I do have safe_mode = off also.
Code:

if ($publish == "yes")
{
$command = "e:scriptspublish.bat";
$result=shell_exec($command); }

The publish.bat file does work and I have proper permissions set in windows, I set everyone full access. Oh, Windows server, IIS6.0, PHP. Error is as follows:

Warning: shell_exec() [function.shell-exec]: Unable to execute 'e:scriptspublish.bat' in

View Replies !
Shell_exec Need Any Configuration?
Anyone can provide me information on how to did the configuration in the unix there to make the shell_exec() can work properly?

View Replies !
Shell_exec() Return Nothing
I ran into a problem with shell_exec() PHP and all files hosting on Redhat I have a html page that allow me to enter a linux command, then submit, then I get the output print out between $output.

when enter command: ls -l /etc, it a list of file and directory on /etc as expected
however, when I tried to execute my program at /etc/earch/esearch (esearch is executable), I received nothing back.

however when I telnet to server, command /etc/earch/esearch does return some text.
i'm sure php was running as same user as telnet.

View Replies !
Shell_exec, Python
Read some garbage tutorial on About.com about embedding my python script inside PHP with shell_exec() but it's not working, as I expected.

Does some kind of configuration have to occur first for this to happen?  I have python installed but I can't run it from anywhere at my dos prompt.  I have to be in the python25 folder (i installed using a windows installer on python.org) for it to work.

I'm running IIS, Win2000, Python 2.5.1, PHP 5.2.3

View Replies !
Shell_exec On LightTPD
I've got a very simple script with shell_exec that's giving me a headache! My server is a NetBSD machine running LightTPD (1.4.8nb1) and php (5.1.1nb2).

I've got the file dummy.php with the following content:

<?php
error_reporting(E_ALL);
$res = shell_exec("pwd 2>&1");
echo $res;
?>

When I access this file through a browser i can't see any output:

http://my.url/dummy.php results in a blank page that loads in no time! No error messages, neither output by the browser or in the log files (php.log and LightTPD's error.log). 

When I use the terminal on the servern it all works fine:

php /path/to/wwwroot/dummy.php gives me the working directory. Doesn't matter from which working directory I execute the command, or which user (I've tried the LightTPD user aswell). It works every time! 

safe_mode is off and there are no disabled_functions!

I've asked around in LightTPD forums, but they say it's a PHP problem. So, I've asked around in (other) PHP forums but noone seems to have any ideas how to solve this! 
Perhaps there are expert users here that can help me, or at least redirect me to some other expert forum.

View Replies !
Specifying Paths Using Shell_exec
i use xampplite locally, winxp.

from PHP, this creates a blank mydump.sql file:

shell_exec("mysqldump --allow-keywords --opt -uroot  mydb > mydump.sql");
but this works fine:

shell_exec("c:xampplitemysqlinmysqldump --allow-keywords --opt -uroot mydb > mydump.sql");

but if i use the second one on my pages, im afraid the code might not work anymore when i transfer the site to my server, because of the path. any suggestions???

View Replies !
Exec()-shell_exec
my server: apache2/php5 and win2k3. I'm able to use shell_exec or exec for dos command that doesn't require auth. I would like to exec certain dos command under "domainuser" "password" .So I'll be able to access remote computer etc...

example:
echo shell_exec(find /i "SomeDataImLookingFor" "RemoteWorkstationc$ ext.txt)

if i use this command in a dosshell under my user session it will return data.Of course if i execute this with PHP on the server with the phpserver account it won't function.

I have been looking for a while on google and forums but i can't find it ,i just need someone to point me to the right page/post/.

View Replies !
Shell_exec - Cd Is Not Working
I have the following script:

$c_path = "/absolute_path_to_some_directory";
$test_cmd = "cd $c_path; ls";
$test_res = shell_exec($test_cmd);

Regardless of where I put the script, when executed, it always lists the contents of the
directory where it is placed, rather than the contents of the some_directory. In other words,it appears that cd is not working. I have verified that path and permissions are correct. PHP is version 4.3.9. What's wrong ?


View Replies !
Shell_exec( ) Function
i trying to use shell_exec on a unix-type platform and can't seem to get it to work. Can anyone help me with the shell_exec command problem? below is the coding of my:

<?php

$output=shell_exec('ll -lart');

echo "$output";
?>

suppose when i run this two line of php coding, there should be a output displayed. but no output displayed.

View Replies !
Exec And Shell_exec
I'm new to running exec commands on php. I've had ffmpeg installed on my server, at /usr/local/bin/ffmpeg (a cmd line video decoder). It's a linux server, running php5.
From looking around the internet, I came up with this code to run it: Code:

View Replies !
Shell_exec On The Localhost?
im expecting notepad to open up when I run the on the localhost???/ But its not

<?php
shell_exec('c:windows
notepad.exe');
?>

View Replies !
Shell_exec And Variables
I'm trying to execute a shell command within a loop to fetch a filename that is stored in an array, but it's not substituting the array with the contents of the array. Here's what I have: Code:

View Replies !
Shell_exec() Output
I am trying to get information from a shell on my server by using shell_exec() but the outputted data is not formatted and I cannot for the life of me figure out how to make the output appear how I want it. For example if I do a whois query I get the full output with returns so it is all dumped on 1 line.

Is there a way to make the outputted data appear the same as if I had performed the same query using SSH? Is there a way to make data from a traceroute appear line by line instead of waiting for the query to execute completly before dumping the data? I am assuming it can be done with Java but I am not sure.

View Replies !
Output From Shell_exec
i'm having trouble with shell_exec. according to php.net the output of the command is returned by shell_exec(), but this is not the case. i've tried exec,passthru and system but can't get the output into a variable. PHP Code:

$ffmpeg = escapeshellcmd('ffmpeg -i "'.$uploadPath['orgVideo'].$org.'"');
$tmp = shell_exec($ffmpeg);        
echo "

";
print_r($tmp);
echo "

"; .....

View Replies !
Shell_exec Not Working On Win2K3
We have PHP 4 installed on Windows 2003 with Apache 2, and the
shell_exec has mysteriously stopped working - it hangs the page rather
then returning anything.

To check it out, I tried shell_exec("dir") which works fine on the
development machine, but not on the live server.

I'm guessing the network guys have done something to the security of
the live server that would cause this - but it's very strange; why
would Apache (running under the default system account) not allow PHP
to run shell_exec statements?

I have checked PHP and it's not in safe mode.

I'm a bit stuck -

View Replies !
Shell_exec Causing CGI ERROR
I have a php page that needs to call a batch script. My test script
has one line: echo test.

I am running Win2003 Server, IIS, and php 4.3.10.

When I first tried running my php script I got an error that said
"unable to execute ...". Then I granted the IIS user execute
privledges to cmd.exe (I know, I know ... security risk).

Once I did that, my script gives me a CGI ERROR - something about http
headers.

I've scoured google groups and come up with nothing that works. I
tried one solution that uses an executable called bgrun.exe. That exe
calls my batch script - still no luck. I've tried exec() and
shell_exec(). No difference. I've tried saving the result to a
variable and not. No difference.

View Replies !
Shell_exec And Perl::Expect.pm
I have a perl script that I'm calling using php's shell_exec that uses
an expect module to go to another system to pull tiff files. The php
perl combination works great when I launch from the commandline:

$php docpull.php

I get the files I want. Everything is perfect.

When I run docpull.php through the web server I get to the expect call
in the perl script where the password is passed and the script fails.
No error in any of the logs or return from either php or perl.

I believe that its an environment issue regarding how php is run through
the web server and what the expect module from perl needs for a pty. I
think this is the case because I can see the scp command output that
perl expect is generating gets to the password but after that there is
no error. Expect needs to have a pty to work with and I think that when
I run through the command line I have one but when I run through apache
I lose access to ptys.

Permissions don't seem to be a problem because I've set up all of the
directories involved with uncomfortably open perms and I've run the
command line version as the Apache user.

I'm reaching at this point. Because of another server limitation I'm
stuck with php 4 and Apache 1.3 for the time being. If anyone has any
other suggestions for pulling files from a remote server I'd be happy to
give them a try, however, the scp with expect will solve lots of other
problems I'll have to deal with.

I'm on slackware linux 10.2

Apache/1.3.33 (Unix)

PHP 4.4.1 (cli) (built: Dec 21 2005 03:44:49)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with Xdebug v2.0.0beta5, Copyright (c) 2002, 2003, 2004, 2005, by
Derick Rethans

This is perl, v5.8.7 built for i486-linux

The expect module I'm using is Expect-1.20

View Replies !
Shell_exec() Works Randomly
In another post I told about PHP not being able to create dates earlier than
1970, so until I can get PHP to do so, I am using a small perlscript to do it.
It looks like this:

//$in[date]*is something like "1943-10-12";

$unixtime = shell_exec("bin/converttime.pl $in[date]");

Problem is, this fails once ever twenty times or so - shell_exec() doesn't
return anything. This is true of another place where I use shell_exec() to run
/usr/bin/cal so I don't think the problem is with the application I am trying
to execute.

View Replies !
Shell_exec() Server (fedora 3.1)
i have full access to the shell of the server (fedora 3.1) but running this code in a php file on xampp server that i have on the same server , i am not getting the output even when i am trying to pipe the output to an html file . Code:

View Replies !
Shell_exec Return Code
The return code of shell_exec function is the return code of the executed command. What happens if  i'm trying to execute a non existing program/script? What is the return code?

ie $output = shell_exec('lss -lart'); and 'lss' is not present in the same folder as the script?

View Replies !
Problem: Exec() And Shell_exec()
I've got the following problem: exec() and shell_exec(), etc. don't give anything back, just the error code 127 For example, the following script:

<?php
exec("cat ./test", $lines, $result);

// or exec("./cat ./test", $lines, $result);
echo "result = $result<br>";
echo "Lines<br>
";
foreach ($lines as $k => $v) {
echo "k=$k v=$v<br>
";
}
?>

View Replies !
Is It Possible To Authenticate Users Running Apache On MacOS X (with PHP 4) And An Active Directory On Windows 2000 Or Windows XP?
From a PHP webpage, is it possible to authenticate users running Apache on MacOS X (with PHP 4) and an active directory on Windows 2000 or Windows XP?

View Replies !
Capture Shell_exec Output With Newlines
I am using shell_exec() to execute an external program, but I can't figure out how to capture all the output with new lines. I'm doing something like this: PHP Code:

View Replies !
Calling A Java Program With Shell_exec()
I couldn't compile php with java support on Mac OS X so I thought I'd
call my java program with shell_exec(). It does work for simple programs
("hello world") but if the program gets more complex php just gets back
an empty string (although on the command line the java program prints
out what I want).

Any ideas why this happens?

View Replies !
Shell_exec And Output Catching Problem
I have a problem with shell_exec. Following code works fine: PHP Code:

View Replies !
Output Of Shell_exec Has Block Characters
I am doing a shell_exec that calls an expect script from the shell. The output that I get back from calling shell_exec has rectangular blocks in a lot of the output. I was wondering if anyone knows what causes these, and how to get rid of them.

View Replies !
Shell_exec() Command - Linux's Shell
I've came up with an issue when trying to work on Linux's shell using PHP
it seems to work when I issue the following commands, shell_exec("iptables -h");, shell_exec("ls"); and shell_exec("ifconfig");

however when I'm trying to do something like this, shell_exec("iptables -L") or shell_exec("iptables restart"); it doesnt seem to work.

View Replies !

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