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?

thanks
giloosh99 [ Mi, 18 Januar 2006 00:16 ] [ ID #1149178 ]

Re: EXEC() Runs process in background

On 17 Jan 2006 15:16:52 -0800, giloosh99 [at] gmail.com wrote:

>Exec, shell_exec, system, popen functions all run the process in the
>background.

They don't normally, unless you do something fairly specific to get them to.

>how can i get it to run the process normally.
>my code looks like this:
><?
>exec("batch_file.bat");
>?>
>
>am i doing anything wrong?

What's in batch_file.bat?

--
Andy Hassall :: andy [at] andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Andy Hassall [ Mi, 18 Januar 2006 00:56 ] [ ID #1149184 ]

Re: EXEC() Runs process in background

giloosh99 [at] gmail.com wrote:
> Exec, shell_exec, system, popen functions all run the process in the
> background.

What do you mean?

What would you like to happen
and what happens instead?

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Pedro Graca [ Mi, 18 Januar 2006 01:17 ] [ ID #1149190 ]

Re: EXEC() Runs process in background

Pedro Graca wrote:

> giloosh99 [at] gmail.com wrote:
>> Exec, shell_exec, system, popen functions all run the process in the
>> background.
>
> What do you mean?
>
> What would you like to happen
> and what happens instead?

I think he/she wants this to run synchronously as opposed to
asynchronously? (so it will execute, wait for it to finish, then come back
to the php script?

Maybe there is some file being created by the shell script/program??

--
a beef jerky site http://www.choicebeefjerky.com.au
not a beef jerky site http://mycoolwheels.com/vote.cmks
most midwives do not have children
Disco Octopus [ Mi, 18 Januar 2006 02:58 ] [ ID #1149194 ]

Re: EXEC() Runs process in background

my batch file (batch_file.bat) starts ms access.
it works fine when i open it by double clicking the file.
the batch file code:
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"

when i run the php script:
<?
exec("batch_file.bat");
?>

i notice the 3 proccess' : php-cgi.exe , cmd.exe, and MSACCESS.EXE all
running under IUSER in the task manager, but i cant see any of them.
the php site itself will not stop searching for the site until it times
out, or until i manually end the proccess through the task manager.
any ideas?
giloosh99 [ Mi, 18 Januar 2006 05:03 ] [ ID #1149199 ]

Re: EXEC() Runs process in background

giloosh, please read <http://cfaj.freeshell.org/google>
before you post again. Thank you.

giloosh wrote:
> my batch file (batch_file.bat) starts ms access.
> it works fine when i open it by double clicking the file.
> the batch file code:
> "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
>
> when i run the php script:
> <?
> exec("batch_file.bat");
> ?>
>
> i notice the 3 proccess' : php-cgi.exe , cmd.exe, and MSACCESS.EXE all
> running under IUSER in the task manager, but i cant see any of them.
> the php site itself will not stop searching for the site until it times
> out, or until i manually end the proccess through the task manager.
> any ideas?

Lets imagine the webserver is in 'IT' department.
Someone in the 'Accounting' department accesses your site.

Can you explain to me why you would like somebody in 'Accounting' to run
MSACCESS.EXE on the webserver?

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Pedro Graca [ Mi, 18 Januar 2006 11:17 ] [ ID #1149217 ]

Re: EXEC() Runs process in background

Hello pedro,
thanks for your kind reply.
i want to call ms access to run some special functions through a
webpage. kind of like a remote control, without really connecting to
the server remotely.
giloosh99 [ Mi, 18 Januar 2006 18:29 ] [ ID #1149272 ]

Re: EXEC() Runs process in background

giloosh wrote:
> my batch file (batch_file.bat) starts ms access.
> it works fine when i open it by double clicking the file.

How long (ie how many seconds) does ms access stay open when you double
click it?

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Pedro Graca [ Mi, 18 Januar 2006 21:17 ] [ ID #1149293 ]

Re: EXEC() Runs process in background

Pedro,
when i double click the batch file it opens a macro within MS access
which calls a function and then tells access to quit.
this is how i use the batch file to run the macro:
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"C:\ACCESS_FILE.mdb" /x "my_macro"

this all happens within 1 sec or 2.


Pedro Graca wrote:
> giloosh wrote:
> > my batch file (batch_file.bat) starts ms access.
> > it works fine when i open it by double clicking the file.
>
> How long (ie how many seconds) does ms access stay open when you double
> click it?
>
> --
> If you're posting through Google read <http://cfaj.freeshell.org/google>
giloosh99 [ Mi, 18 Januar 2006 23:55 ] [ ID #1149319 ]

Re: EXEC() Runs process in background

giloosh top-posted:
> Pedro Graca wrote:
>> giloosh wrote:
>> > my batch file (batch_file.bat) starts ms access.
>> > it works fine when i open it by double clicking the file.
>>
>> How long (ie how many seconds) does ms access stay open when you double
>> click it?
>>
> when i double click the batch file it opens a macro within MS access
> which calls a function and then tells access to quit.
>
> this all happens within 1 sec or 2.

Can you try to run that batch file as the user your webserver runs
under? Something like right-click and "Run as different user" ... I
can't remember exactly how to do it; you'll have to experiment.

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Pedro Graca [ Do, 19 Januar 2006 01:17 ] [ ID #1149325 ]

Re: EXEC() Runs process in background

On Tue, 17 Jan 2006 23:56:47 +0000, Andy Hassall wrote:

> On 17 Jan 2006 15:16:52 -0800, giloosh99 [at] gmail.com wrote:
>
>>Exec, shell_exec, system, popen functions all run the process in the
>>background.
>
> They don't normally, unless you do something fairly specific to get them to.
>
>>how can i get it to run the process normally.
>>my code looks like this:
>><?
>>exec("batch_file.bat");
>>?>
>>
>>am i doing anything wrong?
>
> What's in batch_file.bat?


I think your problem is MS Access is forking and running in the
background, causing the BAT to exit.

Open up a command window and run your bat file in it. How long before your
BAT exits and goes back to the command prompt? If the answer is "before I
close MS Access", then there's nothing you can do about it.

-Rob
Robin Haswell [ Do, 19 Januar 2006 12:11 ] [ ID #1149375 ]

Re: EXEC() Runs process in background

"Robin Haswell" <rob [at] digital-crocus.com> wrote in message
news:pan.2006.01.19.11.11.02.478252 [at] digital-crocus.com...
> On Tue, 17 Jan 2006 23:56:47 +0000, Andy Hassall wrote:
>
>> On 17 Jan 2006 15:16:52 -0800, giloosh99 [at] gmail.com wrote:
>>
>>>Exec, shell_exec, system, popen functions all run the process in the
>>>background.
>>
>> They don't normally, unless you do something fairly specific to get them
>> to.
>>
>>>how can i get it to run the process normally.
>>>my code looks like this:
>>><?
>>>exec("batch_file.bat");
>>>?>
>>>
>>>am i doing anything wrong?
>>
>> What's in batch_file.bat?
>
>
> I think your problem is MS Access is forking and running in the
> background, causing the BAT to exit.


do a start, run, cmd to get a cmd shell.
type in start /?
and look at your options. I think you can get the batch file to wait for
the process to finish before continuing.
and BTW, use .CMD instead of .BAT - it will give you these options. I can't
remember if .BAT files bring up command.com rather than cmd.exe. I think
they do. that is, if you are on an NT/2000/xp box. .CMD files will also
give you long filenames by default, and a bunch of extra commands and
switches. try doing a set /? and watch the fireworks. batch files can loop
and count and do calculations with CMD. (I'm sure this won't impress the
UNIX folk :-) )


>
> Open up a command window and run your bat file in it. How long before your
> BAT exits and goes back to the command prompt? If the answer is "before I
> close MS Access", then there's nothing you can do about it.
>
> -Rob
>
Jim Michaels [ Sa, 21 Januar 2006 03:36 ] [ ID #1152266 ]

Re: EXEC() Runs process in background

"Jim Michaels" <jmichae3 [at] yahoo.com> wrote in message
news:uJednQOjr726A0zenZ2dnUVZ_tmdnZ2d [at] comcast.com...
> "Robin Haswell" <rob [at] digital-crocus.com> wrote in message
> news:pan.2006.01.19.11.11.02.478252 [at] digital-crocus.com...
>> On Tue, 17 Jan 2006 23:56:47 +0000, Andy Hassall wrote:
>>
>>> On 17 Jan 2006 15:16:52 -0800, giloosh99 [at] gmail.com wrote:
>>>
>>>>Exec, shell_exec, system, popen functions all run the process in the
>>>>background.
>>>
>>> They don't normally, unless you do something fairly specific to get
>>> them to.
>>>
>>>>how can i get it to run the process normally.
>>>>my code looks like this:
>>>><?
>>>>exec("batch_file.bat");
>>>>?>
>>>>
>>>>am i doing anything wrong?
>>>
>>> What's in batch_file.bat?
>>
>>
>> I think your problem is MS Access is forking and running in the
>> background, causing the BAT to exit.
>
>
> do a start, run, cmd to get a cmd shell.
> type in start /?
> and look at your options. I think you can get the batch file to wait for
> the process to finish before continuing.
> and BTW, use .CMD instead of .BAT - it will give you these options. I
> can't remember if .BAT files bring up command.com rather than cmd.exe. I
> think they do. that is, if you are on an NT/2000/xp box. .CMD files will
> also give you long filenames by default, and a bunch of extra commands and
> switches. try doing a set /? and watch the fireworks. batch files can
> loop and count and do calculations with CMD. (I'm sure this won't impress
> the UNIX folk :-) )
>

try
start /wait somefile.mdb /x somemacro
in your .cmd file. it might also work in your .BAT file.


>
>>
>> Open up a command window and run your bat file in it. How long before
>> your
>> BAT exits and goes back to the command prompt? If the answer is "before I
>> close MS Access", then there's nothing you can do about it.
>>
>> -Rob
>>
>
>
Jim Michaels [ Sa, 21 Januar 2006 20:59 ] [ ID #1152306 ]

Re: EXEC() Runs process in background

<--quote
I think your problem is MS Access is forking and running in the
background, causing the BAT to exit.

Open up a command window and run your bat file in it. How long before
your
BAT exits and goes back to the command prompt? If the answer is "before
I
close MS Access", then there's nothing you can do about it.
quote-->

ms access closes before the cmd promt closes when i run the bat file
manually.
it also runs when i run the .bat file through start>run>cmd shell. so
that is not the problem
this is obviously not a ms access issue. no matter what file i try to
run in php, it always runs in the background and never closes untill i
end the proccess through the task manager.
i am using windows xp pro if that makes any diff at all?
giloosh99 [ Mo, 23 Januar 2006 01:27 ] [ ID #1154847 ]
PHP » comp.lang.php » EXEC() Runs process in background

Vorheriges Thema: image manipulation in safe mode
Nächstes Thema: only two concurrent php scripts at a time