Connecting Tech Pros Worldwide Forums | Help | Site Map

EXEC() Runs process in background

giloosh99@gmail.com
Guest
 
Posts: n/a
#1: Jan 17 '06
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


Andy Hassall
Guest
 
Posts: n/a
#2: Jan 18 '06

re: EXEC() Runs process in background


On 17 Jan 2006 15:16:52 -0800, giloosh99@gmail.com wrote:
[color=blue]
>Exec, shell_exec, system, popen functions all run the process in the
>background.[/color]

They don't normally, unless you do something fairly specific to get them to.
[color=blue]
>how can i get it to run the process normally.
>my code looks like this:
><?
>exec("batch_file.bat");
>?>
>
>am i doing anything wrong?[/color]

What's in batch_file.bat?

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Pedro Graca
Guest
 
Posts: n/a
#3: Jan 18 '06

re: EXEC() Runs process in background


giloosh99@gmail.com wrote:[color=blue]
> Exec, shell_exec, system, popen functions all run the process in the
> background.[/color]

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>
Disco Octopus
Guest
 
Posts: n/a
#4: Jan 18 '06

re: EXEC() Runs process in background


Pedro Graca wrote:
[color=blue]
> giloosh99@gmail.com wrote:[color=green]
>> Exec, shell_exec, system, popen functions all run the process in the
>> background.[/color]
>
> What do you mean?
>
> What would you like to happen
> and what happens instead?[/color]

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
giloosh
Guest
 
Posts: n/a
#5: Jan 18 '06

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?

Pedro Graca
Guest
 
Posts: n/a
#6: Jan 18 '06

re: EXEC() Runs process in background


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

giloosh wrote:[color=blue]
> 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?[/color]

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>
giloosh
Guest
 
Posts: n/a
#7: Jan 18 '06

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.

Pedro Graca
Guest
 
Posts: n/a
#8: Jan 18 '06

re: EXEC() Runs process in background


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

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>
giloosh
Guest
 
Posts: n/a
#9: Jan 18 '06

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:[color=blue]
> giloosh wrote:[color=green]
> > my batch file (batch_file.bat) starts ms access.
> > it works fine when i open it by double clicking the file.[/color]
>
> 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>[/color]

Pedro Graca
Guest
 
Posts: n/a
#10: Jan 19 '06

re: EXEC() Runs process in background


giloosh top-posted:[color=blue]
> Pedro Graca wrote:[color=green]
>> giloosh wrote:[color=darkred]
>> > my batch file (batch_file.bat) starts ms access.
>> > it works fine when i open it by double clicking the file.[/color]
>>
>> How long (ie how many seconds) does ms access stay open when you double
>> click it?
>>[/color]
> 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.[/color]

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>
Robin Haswell
Guest
 
Posts: n/a
#11: Jan 19 '06

re: EXEC() Runs process in background


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


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

Jim Michaels
Guest
 
Posts: n/a
#12: Jan 21 '06

re: EXEC() Runs process in background


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


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 :-) )

[color=blue]
>
> 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
>[/color]


Jim Michaels
Guest
 
Posts: n/a
#13: Jan 21 '06

re: EXEC() Runs process in background



"Jim Michaels" <jmichae3@yahoo.com> wrote in message
news:uJednQOjr726A0zenZ2dnUVZ_tmdnZ2d@comcast.com. ..[color=blue]
> "Robin Haswell" <rob@digital-crocus.com> wrote in message
> news:pan.2006.01.19.11.11.02.478252@digital-crocus.com...[color=green]
>> On Tue, 17 Jan 2006 23:56:47 +0000, Andy Hassall wrote:
>>[color=darkred]
>>> On 17 Jan 2006 15:16:52 -0800, giloosh99@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?[/color]
>>
>>
>> I think your problem is MS Access is forking and running in the
>> background, causing the BAT to exit.[/color]
>
>
> 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 :-) )
>[/color]

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

[color=blue]
>[color=green]
>>
>> 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
>>[/color]
>
>[/color]


giloosh
Guest
 
Posts: n/a
#14: Jan 23 '06

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?

Closed Thread