By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

exec php

P: n/a
Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
$return_value = exec('path_to_exe_file');
echo $return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?
Dec 21 '07 #1
Share this Question
Share on Google+
26 Replies


P: n/a
On Dec 21, 3:01*pm, wart...@hotmail.com wrote:
Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to *work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
* *$return_value = exec('path_to_exe_file');
* *echo $return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?
Bad combination! Apache server on Windows 2003 server. Thy combination
really diminishes the performance and may cause those freezes

You should switch to GNU/Linux-Apache/php or Windows2003/IIS/Asp.NET

Dec 21 '07 #2

P: n/a
Since the exec() function isn't expecting anything back, it might be worth
trying either "shell_exec()" or "system()" since those would get back some
output from the program being accessed.

Tom
The thing is that the php function is expecting something back. Thus
getting the result of the exec command is needed by the php script.
About the bad combination: The site is running windows media server,
so I cannot go to linux. And I cannot recreate a whole site, a big
one, in asp.net!
Dec 21 '07 #3

P: n/a
On Dec 21, 8:01 am, wart...@hotmail.com wrote:
Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
$return_value = exec('path_to_exe_file');
echo $return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?
First, what kind of program are you calling? Whats it do?
Second, please tell me you looked up Exec on the php.net site and read
all the comments made by folks who have done or attempted to do what
you are trying. The answer might be right there!
Third, what kind of resources does the called program use? Are you
running out of memory? are you running out of connections to a
database? What is your take on why the program is failing? What
permissions does the called program have? What permsissions does it
need?
Dec 22 '07 #4

P: n/a
First, what kind of program are you calling? *Whats it do?
Its a few programs, made in c#. The programs mostly make operations on
the windows media server. They create publishing point, for example,
on the fly.
Second, please tell me you looked up Exec on the php.net site and read
all the comments made by folks who have done or attempted to do what
you are trying. *The answer might be right there!
I had a look there. But no one that got the same king of problem.
Third, what kind of resources does the called program use? *Are you
running out of memory? *are you running out of connections to a
database? *What is your take on why the program is failing? *What
permissions does the called program have? *What permsissions does it
need?-
I put log functions both in the php-script and in the c# app.

I restart the server, and everything works. But then, after may one
day, for some reason, one of the c# app (can be any of them) freezes
during the execution, and before it can returns.

The php-log says that, well, nothing. It stops when it has to show the
return value got from the c# app.

The C# app doesnt catch. That is the big problem. The log function in
the c# app is located at the end of the try statement. And exactly
before the return statement. In the log file I try to write the return
value. But it is blank, for some reason.

Worst of all, maybe, is that the c# app is runnable from the command
line. Always. And it executes returning the value. So the problem, as
I see it, is that suddenly the php-interpretor hangs up when running
exec.

Yes, this is obvious, as I created a dummy c# app, one that only
returns hello world. Well, after the php-interpretor (or is it apache
stuff?) hangs up, I cannot either get the return value from that app.

Is it an apache problem? What do you think guys? But the error log
doesnt have any trace of problems with the exec...


Dec 23 '07 #5

P: n/a
Csaba Gabor said:
"something like that" covers a lot of ground. It could have some
bearing, though it is not obvious. Firstly, you are saying that the
program does what it should do. That would imply that the paths/
environment vars are correct. However, if it affects the cleanup of
the program somehow it could be material. Also, it might be affected
by the "Allow service to interact with desktop" setting that you can
make on Apache/your web server (under Control Panel \ Services).

Csaba
Gotta love the ambiguous errors. I don't think he said it does what it
should do, though. I know when I ran exec without the paths right, I
didn't get any server errors either, and I had the same kind of issue
he's describing.

So it might cover a lot of ground, but it's kinda always better to have
a bunch of ideas, no matter how much they cover, I tink.

~A!
Dec 24 '07 #6

P: n/a
On 24 Dec, 08:48, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:
Csaba Gabor said:
"something like that" covers a lot of ground. *It could have some
bearing, though it is not obvious. *Firstly, you are saying that the
program does what it should do. *That would imply that the paths/
environment vars are correct. *However, if it affects the cleanup of
the program somehow it could be material. *Also, it might be affected
by the "Allow service to interact with desktop" setting that you can
make on Apache/your web server (under Control Panel \ Services).
Csaba

Gotta love the ambiguous errors. I don't think he said it does what it
should do, though. I know when I ran exec without the paths right, I
didn't get any server errors either, and I had the same kind of issue
he's describing.

So it might cover a lot of ground, but it's kinda always better to have
a bunch of ideas, no matter how much they cover, I tink.

~A!
Yes, the c# programs do what they have to do. They work! They work 2
hours, 3 hours, maybe 1 day. And then suddenly it stops to work.

It is extrmly frustating. I have tried to put logs both in the php-
script and in the c# app. Nothing. Not an exception. Nothing.

Again: if I have a simple C# app that only have an Hello World, then
the php script, or to be more exact the exec call from the php-script
to the c# app, seems like going in an infinite loop. Even thought
there is no loop there. The exec waits, for ever...

No error in error.log fo r apache. And, no problem in continuing with
running the server. I can always view other pages. The only problem, a
very big problem, is that at a certain point the exec function hangs
up.
Dec 24 '07 #7

P: n/a
On 24 Dec, 10:51, wart...@hotmail.com wrote:
On 24 Dec, 08:48, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:


Csaba Gabor said:
"something like that" covers a lot of ground. *It could have some
bearing, though it is not obvious. *Firstly, you are saying that the
program does what it should do. *That would imply that the paths/
environment vars are correct. *However, if it affects the cleanup of
the program somehow it could be material. *Also, it might be affected
by the "Allow service to interact with desktop" setting that you can
make on Apache/your web server (under Control Panel \ Services).
Csaba
Gotta love the ambiguous errors. I don't think he said it does what it
should do, though. I know when I ran exec without the paths right, I
didn't get any server errors either, and I had the same kind of issue
he's describing.
So it might cover a lot of ground, but it's kinda always better to have
a bunch of ideas, no matter how much they cover, I tink.
~A!

Yes, the c# programs do what they have to do. They work! They work 2
hours, 3 hours, maybe 1 day. And then suddenly it stops to work.

It is extrmly frustating. I have tried to put logs both in the php-
script and in the c# app. Nothing. Not an exception. Nothing.

Again: if I have a simple C# app that only have an Hello World, then
the php script, or to be more exact the exec call from the php-script
to the c# app, seems like going in an infinite loop. Even thought
there is no loop there. The exec waits, for ever...

No error in error.log fo r apache. And, no problem in continuing with
running the server. I can always view other pages. The only problem, a
very big problem, is that at a certain point the exec function hangs
up.- Dölj citerad text -

- Visa citerad text -
Maybe another intresting thing.

The c# app that I try to run after exec begins to freeze, looks
something like that:

static void Main(string[] args){
tw.WriteLine("Before at " + DateTime.Now);
Console.Write("error test");
tw.WriteLine("After at " + DateTime.Now);
tw.Close();
}

In the c# app there is nothing else than this. The funny thing is that
in the log can see:

Before at (date)
After at (date)

Console.writeline should have been executed right? It is stated before
the second log line...
Dec 24 '07 #8

P: n/a
I am quite sure that the problem is located in the function exec. At
some point, that function hangs up. Why? Not easy to know. But is it
possible to log it? Ordinary self made log function doesnt give
anything. Apache error log doesnt give anything either. How can I
analyze what is going on with that function?

Dec 27 '07 #9

P: n/a
wa*****@hotmail.com said:
I am quite sure that the problem is located in the function exec. At
some point, that function hangs up. Why? Not easy to know. But is it
possible to log it? Ordinary self made log function doesnt give
anything. Apache error log doesnt give anything either. How can I
analyze what is going on with that function?
If they work for a while and then suddenly stop, have you checked the OS
error logs? If there is an error happening, it's going to be recorded
somewhere. It could be something as simple as your app filling up memory
somehow, or having too many open threads to it from the OS' viewpoint.

With exec, if it goes out and executes successfully once, then it's most
likely not broken there, and you might need to go deeper to get to any
kind of issues. Maybe open up the server process list and watch what's
happening while it runs, if you can.
Good luck, chasing this one is going to cost you a bunch of time, sounds
like.
~A!

--
Anthony Levensalor
an*****@mypetprogrammer.com
Dec 27 '07 #10

P: n/a
Betikci Boris wrote:
On Dec 21, 3:01 pm, wart...@hotmail.com wrote:
>Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
$return_value = exec('path_to_exe_file');
echo $return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?

Bad combination! Apache server on Windows 2003 server. Thy combination
really diminishes the performance and may cause those freezes

You should switch to GNU/Linux-Apache/php or Windows2003/IIS/Asp.NET

Horse hockey. Apache runs quite well on Windows - much better than IIS does.

But I do agree Linux is a better os.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 28 '07 #11

P: n/a
wa*****@hotmail.com wrote:
On 24 Dec, 10:51, wart...@hotmail.com wrote:
>On 24 Dec, 08:48, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:


>>Csaba Gabor said:
"something like that" covers a lot of ground. It could have some
bearing, though it is not obvious. Firstly, you are saying that the
program does what it should do. That would imply that the paths/
environment vars are correct. However, if it affects the cleanup of
the program somehow it could be material. Also, it might be affected
by the "Allow service to interact with desktop" setting that you can
make on Apache/your web server (under Control Panel \ Services).
Csaba
Gotta love the ambiguous errors. I don't think he said it does what it
should do, though. I know when I ran exec without the paths right, I
didn't get any server errors either, and I had the same kind of issue
he's describing.
So it might cover a lot of ground, but it's kinda always better to have
a bunch of ideas, no matter how much they cover, I tink.
~A!
Yes, the c# programs do what they have to do. They work! They work 2
hours, 3 hours, maybe 1 day. And then suddenly it stops to work.

It is extrmly frustating. I have tried to put logs both in the php-
script and in the c# app. Nothing. Not an exception. Nothing.

Again: if I have a simple C# app that only have an Hello World, then
the php script, or to be more exact the exec call from the php-script
to the c# app, seems like going in an infinite loop. Even thought
there is no loop there. The exec waits, for ever...

No error in error.log fo r apache. And, no problem in continuing with
running the server. I can always view other pages. The only problem, a
very big problem, is that at a certain point the exec function hangs
up.- Dölj citerad text -

- Visa citerad text -

Maybe another intresting thing.

The c# app that I try to run after exec begins to freeze, looks
something like that:

static void Main(string[] args){
tw.WriteLine("Before at " + DateTime.Now);
Console.Write("error test");
tw.WriteLine("After at " + DateTime.Now);
tw.Close();
}

In the c# app there is nothing else than this. The funny thing is that
in the log can see:

Before at (date)
After at (date)

Console.writeline should have been executed right? It is stated before
the second log line...
The problem isn't in your exec() call. Rather, (from an earlier post)
you need to find out why your program is not returning a value.

exec() works quite well. I've never found a problem in it - although I
have found problems in my code at times.

As for the Console.writeline - try a C# newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 28 '07 #12

P: n/a
Oh well. In the C# newsgroup no one could help me. They dont seem to
have any idea o nwhat is going on. I tryed to explain the problem as
detailed as possible, but nothing..
Today I tryed something quite basic. It sounded as it was a good
solution, so bad that I hadnt tried it before. Setting time limit. The
thing was that the time limit in php ini is set to 0 on the server.

So I put this in a test script:

set_time_limit(10);
try{
echo 'before exec';
log('before exec');
$ret = exec('path_to_exx_file.exe');
echo 'exec returned ' . $ret;
log('exec returned ' . $ret);
}
catch(Exception $e){
echo 'failed due to: ' . $e;
log('failed due to: ' . $e);
}

Note that this script was calling a simple Hello world c# program.

But neither this helped me. The script will run for ever.

Is there really not anyone that can help me out, just give me some
good hint of what the problem can be? Arent they any gurus there out??

Jan 17 '08 #13

P: n/a
wa*****@hotmail.com wrote:
Oh well. In the C# newsgroup no one could help me. They dont seem to
have any idea o nwhat is going on. I tryed to explain the problem as
detailed as possible, but nothing..
Today I tryed something quite basic. It sounded as it was a good
solution, so bad that I hadnt tried it before. Setting time limit. The
thing was that the time limit in php ini is set to 0 on the server.

So I put this in a test script:

set_time_limit(10);
try{
echo 'before exec';
log('before exec');
$ret = exec('path_to_exx_file.exe');
echo 'exec returned ' . $ret;
log('exec returned ' . $ret);
}
catch(Exception $e){
echo 'failed due to: ' . $e;
log('failed due to: ' . $e);
}

Note that this script was calling a simple Hello world c# program.

But neither this helped me. The script will run for ever.

Is there really not anyone that can help me out, just give me some
good hint of what the problem can be? Arent they any gurus there out??

PHP can only time out when it is in control. Once it passes control off
to the C# program, PHP can't time out until control is returned.

And there are PHP gurus here. But this isn't a PHP problem - PHP isn't
even involved after the call to exec().

But I also sympathize with you. These things aren't easy to find.

Maybe start a little more basic. What happens if you just have a C#
program which does nothing but return? What if you don't have any
output from the C# program?

BTW - posting your C# code here won't help. Most of us won't understand
it, anyway.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 17 '08 #14

P: n/a
PHPcan only time out when it is in control. *Once it passes control off
to the C# program,PHPcan't time out until control is returned.

And there arePHPgurus here. *But this isn't aPHPproblem -PHPisn't
even involved after the call to exec().

But I also sympathize with you. *These things aren't easy to find.

Maybe start a little more basic. *What happens if you just have a C#
program which does nothing but return? *What if you don't have any
output from the C# program?

BTW - posting your C# code here won't help. *Most of us won't understand
it, anyway.
Thank for the support Jerry. I was just a little bit frustrated, thats
why I told that think about gurus.
Well I will try to call a c# that doesnt return anything. And I will
see if exec runs forever even in that case. Im just waiting for the
next time the server hangs up, which will happen in the next few hours
or next few days (I think the site web application worked without
hanging up for more than a couple of days). I'll be back soon..


Jan 17 '08 #15

P: n/a
Here we are. The problem showed up again. The php script looks like
this:

***********************************
set_time_limit(20);
write_to_log("Beginning at " . date('Y-m-d H:i:s'));
$exec_command = 'app.exe';
$str = "Before at " . date('Y-m-d H:i:s');
write_to_log("Before at " . date('Y-m-d H:i:s'));
try {
write_to_log("trying at " . date('Y-m-d H:i:s'));
exec($exec_command);
write_to_log("after execution at " . date('Y-m-d H:i:s'));
write_to_log("Ends at " . date('Y-m-d H:i:s'));
}
catch (Exception $e) {
write_to_log("message was " . $e->getMessage());
}
***********************************

The log file, when everything works, contains this:

***********************************
Beginning at 2008-01-17 19:02:09
Before at 2008-01-17 19:02:09
trying at 2008-01-17 19:02:09
after execution at 2008-01-17 19:02:09
Ends at 2008-01-17 19:02:09
***********************************

The log file, when it hangs up, contains this:

***********************************
Beginning at 2008-01-17 21:10:52
Before at 2008-01-17 21:10:52
trying at 2008-01-17 21:10:52
***********************************

I used another c# app, a one that doesnt return anything. But the exec
still hangs up. Most people here dont know anything about c#, but
Ipost it cause its very simple stuff, and I think every programmer
should understand it, even if it is a different syntax:

***********************************
static void Main(string[] args){
TextWriter tw = new StreamWriter("C:\\logs\\app.txt",
true);
tw.WriteLine("beginning at " + DateTime.Now);
tw.WriteLine("ending at " + DateTime.Now);
tw.Close();
}
***********************************

The app is only writing to the log file. And is not printing anything
to the console (which corresponds to the return value that the php
script use to get).

The log file for the c# app, when everything works, looks like this:

***********************************
beginning at 2008-01-17 21:10:52
ending at 2008-01-17 21:10:52
***********************************

And, the funny thing, it looks exactly the same, even after the exec
hangs up. The c# is executed, always, when called from php through
php. But, when saying that exec is hanging up, it means that it doesnt
return. Thats all.
Jan 17 '08 #16

P: n/a
wa*****@hotmail.com wrote:
Here we are. The problem showed up again. The php script looks like
this:

***********************************
set_time_limit(20);
write_to_log("Beginning at " . date('Y-m-d H:i:s'));
$exec_command = 'app.exe';
$str = "Before at " . date('Y-m-d H:i:s');
write_to_log("Before at " . date('Y-m-d H:i:s'));
try {
write_to_log("trying at " . date('Y-m-d H:i:s'));
exec($exec_command);
write_to_log("after execution at " . date('Y-m-d H:i:s'));
write_to_log("Ends at " . date('Y-m-d H:i:s'));
}
catch (Exception $e) {
write_to_log("message was " . $e->getMessage());
}
***********************************

The log file, when everything works, contains this:

***********************************
Beginning at 2008-01-17 19:02:09
Before at 2008-01-17 19:02:09
trying at 2008-01-17 19:02:09
after execution at 2008-01-17 19:02:09
Ends at 2008-01-17 19:02:09
***********************************

The log file, when it hangs up, contains this:

***********************************
Beginning at 2008-01-17 21:10:52
Before at 2008-01-17 21:10:52
trying at 2008-01-17 21:10:52
***********************************

I used another c# app, a one that doesnt return anything. But the exec
still hangs up. Most people here dont know anything about c#, but
Ipost it cause its very simple stuff, and I think every programmer
should understand it, even if it is a different syntax:

***********************************
static void Main(string[] args){
TextWriter tw = new StreamWriter("C:\\logs\\app.txt",
true);
tw.WriteLine("beginning at " + DateTime.Now);
tw.WriteLine("ending at " + DateTime.Now);
tw.Close();
}
***********************************

The app is only writing to the log file. And is not printing anything
to the console (which corresponds to the return value that the php
script use to get).

The log file for the c# app, when everything works, looks like this:

***********************************
beginning at 2008-01-17 21:10:52
ending at 2008-01-17 21:10:52
***********************************

And, the funny thing, it looks exactly the same, even after the exec
hangs up. The c# is executed, always, when called from php through
php. But, when saying that exec is hanging up, it means that it doesnt
return. Thats all.
Interesting. So the C# program writes its final log entry and something
hangs.

I would say it's in one of two places - either the C# program, or, more
likely, Windows. The reason I say the latter is because your C# program
just goes through its termination code and back to Windows. Windows
should then return control to PHP.

It doesn't look like this last part is getting done - there isn't a lot
for PHP to do before it continues execution of your program.

Is there anything in your Event Logs showing a problem? Can you still
see the C# process running in the system?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 18 '08 #17

P: n/a
This is a php group, most people dont know about c#. So my question, a
php-related one, is: what strategy would you use n this case? To solve
the problem, or at least to do something about this. I mean, you have
a few php-scripts whose execution is dependent on an external program.
What would you do in a case like this? When ou know that sometimes the
execution can fail (and worst of all make, more or less, a whole web
app to hang up), and you just want to exit, in those cases? What would
you do, guys?
As Jerry said, the try and catch will not work, as php will loose the
control when the exec will be called.
Jan 18 '08 #18

P: n/a
Interesting. *So the C# program writes its final log entry and something
hangs.

I would say it's in one of two places - either the C# program, or, more
likely, Windows. *The reason I say the latter is because your C# program
just goes through its termination code and back to Windows. *Windows
should then return control toPHP.

It doesn't look like this last part is getting done - there isn't a lot
forPHPto do before it continues execution of your program.

Is there anything in your Event Logs showing a problem? *Can you still
see the C# process running in the system?
Well, It happened again now. So I opened the task manager. Among the
processes there was not any of the c# programs. Then I had a looko at
the event logs. I dont know much about it, so I googled and it seems
that the command eventwvr opens the log im intresting in.

It showes a lot of errors, but I could not find one that was related
to any c# programs. I think I will research a little about detecting
errors of aplpication in the windows log.

Jan 18 '08 #19

P: n/a
wa*****@hotmail.com wrote:
>Interesting. So the C# program writes its final log entry and something
hangs.

I would say it's in one of two places - either the C# program, or, more
likely, Windows. The reason I say the latter is because your C# program
just goes through its termination code and back to Windows. Windows
should then return control toPHP.

It doesn't look like this last part is getting done - there isn't a lot
forPHPto do before it continues execution of your program.

Is there anything in your Event Logs showing a problem? Can you still
see the C# process running in the system?

Well, It happened again now. So I opened the task manager. Among the
processes there was not any of the c# programs. Then I had a looko at
the event logs. I dont know much about it, so I googled and it seems
that the command eventwvr opens the log im intresting in.

It showes a lot of errors, but I could not find one that was related
to any c# programs. I think I will research a little about detecting
errors of aplpication in the windows log.

The problem is it may not be directly related to the C# application. It
could be something in the system, the C# libraries or about anything.

And you should be able to find your event viewer under "Administrative
tools". It's not necessarily bad to have some entries, i.e. Windows
will place startup messages in there. But you do need to at least
understand the cause of the errors, if not fix them.

Check a Windows newsgroup for more info here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 18 '08 #20

P: n/a
On Jan 18, 12:08 am, wart...@hotmail.com wrote:
This is a php group, most people dont know about c#. So my question, a
php-related one, is: what strategy would you use n this case? To solve
the problem, or at least to do something about this. I mean, you have
a few php-scripts whose execution is dependent on an external program.
What would you do in a case like this? When ou know that sometimes the
execution can fail (and worst of all make, more or less, a whole web
app to hang up), and you just want to exit, in those cases? What would
you do, guys?
As Jerry said, the try and catch will not work, as php will loose the
control when the exec will be called.
Given your seemingly random, but consisent failure,
here is a possible approach (but I'd look at popen below, first):

In your php program, create a scheduled task whose only function
will be to execute your exec right away (this can either be
done by scheduling the task to run at the top of the next minute
or schtasks can explicitly cause the task to run (but it
requires a one line exec call) - you must ensure a unique
id). This way your original program is not
tied to the completion of your scheduled script.
The scheduled script (or rather, whatever is execed) could write
a file or leave some tracks for the original script to detect
that it has gotten sufficiently far if that's a requirement.

You have a few ways of going about this. On Windows, you can
use either AT or SchTasks. The latter may be worked with as a
COM object (otherwise you'll be looking at some version of exec).

---------

Also, as regards your exec, something I would investigate
before total frustration (if that point hasn't already been
reached) is a http://php.net/popen variant. By the way,
the exec family of functions (or something related to them)
was revised over the last year especially in regards to
being executed from php-win.exe so it's probably a good
idea to have a recent copy of php.

Csaba Gabor from Vienna
Jan 19 '08 #21

P: n/a
Given your seemingly random, but consisent failure,
here is a possible approach (but I'd look at popen below, first):

In yourphpprogram, create a scheduled task whose only function
will be to execute your exec right away (this can either be
done by scheduling the task to run at the top of the next minute
or schtasks can explicitly cause the task to run (but it
requires a one line exec call) - you must ensure a unique
id). *This way your original program is not
tied to the completion of your scheduled script.
The scheduled script (or rather, whatever is execed) could write
a file or leave some tracks for the original script to detect
that it has gotten sufficiently far if that's a requirement.

You have a few ways of going about this. *On Windows, you can
use either AT or SchTasks. *The latter may be worked with as a
COM object (otherwise you'll be looking at some version of exec).
I must confess I dont really understand how to implement this, and
neither know if this is something for me. I mean the kind of webapp I
have will probably not gain benefits by using this approach.
Also, as regards your exec, something I would investigate
before total frustration (if that point hasn't already been
reached) is ahttp://php.net/popenvariant. *By the way,
the exec family of functions (or something related to them)
was revised over the last year especially in regards to
being executed fromphp-win.exe so it's probably a good
idea to have a recent copy ofphp.
Yes I will try this too. When the exec hangs up I will try to call a
test php-script that, in turn, only calls a dummy c# app, one that
only prints hello world. If it will not help, I think I will try to
replace all my calls to exec with popen. And see if that will help...
Anyway the first thing I will do is to replace the php-copy with a
newer one(it is 5.2.1 now). Cause I reallt dont know how to face this
problem anymore. Thanks all for the help, will be back in case of
better news.

Jan 20 '08 #22

P: n/a
Ok, an interesting thing. The exec hanged up now. But I was not
inlogged. This time I opened task manager and selected "Show process
from all user" (should have done this before).

Now I can see what is going on. It was not difficult to guess, but at
least I have seen that now. Everytime, after the exec begins to give
problems, the exec is called, then I can see in the task manager that
there is one of the processes called by exec running. So If I open the
browser and go to: test.php, that in turn will do exec (hello.exe), a
new process is added in the task manager, so right now I have a lot of
hello.exe running...
Jan 21 '08 #23

P: n/a
wa*****@hotmail.com wrote:
Ok, an interesting thing. The exec hanged up now. But I was not
inlogged. This time I opened task manager and selected "Show process
from all user" (should have done this before).

Now I can see what is going on. It was not difficult to guess, but at
least I have seen that now. Everytime, after the exec begins to give
problems, the exec is called, then I can see in the task manager that
there is one of the processes called by exec running. So If I open the
browser and go to: test.php, that in turn will do exec (hello.exe), a
new process is added in the task manager, so right now I have a lot of
hello.exe running...
So your hello.exe isn't terminating. I guess you need to find out why
next. PHP won't continue until the exe finishes, of course.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 21 '08 #24

P: n/a
So your hello.exe isn't terminating. *I guess you need to find out why
next. *PHPwon't continue until the exe finishes, of course.
yes, hello wolrd is not terminating. Well, hehe, why?
The custommized php error log doesnt show anything, and its quite
normal if it doesnt, yes.
The customized c# error log doesnt catch, execute until the end, and
doesnt report any error in the log.
The apache error log DOES NOT show anything wrong.
The windows event log DOESN NOT log error inprogram execution, sigh

The only thing I can work with right now, is the memory leak, if there
is a memory leak. I guess I have to ask in an apache group. But, I try
to ask it here also:

When starting apache, the values retrieved from windows task manager
are:

Mem usage: 16 968 K
VM size: 16 696 K
Handles: 705
After about a day, the values are:

httpd.exe
Mem usage: 58 123 K
VM size: 67 676 K
Handles: 829

Does this sound wrong?

Jan 21 '08 #25

P: n/a
wa*****@hotmail.com wrote:
>So your hello.exe isn't terminating. I guess you need to find out why
next. PHPwon't continue until the exe finishes, of course.
yes, hello wolrd is not terminating. Well, hehe, why?
The custommized php error log doesnt show anything, and its quite
normal if it doesnt, yes.
The customized c# error log doesnt catch, execute until the end, and
doesnt report any error in the log.
The apache error log DOES NOT show anything wrong.
The windows event log DOESN NOT log error inprogram execution, sigh

The only thing I can work with right now, is the memory leak, if there
is a memory leak. I guess I have to ask in an apache group. But, I try
to ask it here also:

When starting apache, the values retrieved from windows task manager
are:

Mem usage: 16 968 K
VM size: 16 696 K
Handles: 705
After about a day, the values are:

httpd.exe
Mem usage: 58 123 K
VM size: 67 676 K
Handles: 829

Does this sound wrong?

I have no idea. There are way more things going on in the system than
just Apache and PHP.

What you need to do is work with the MS admin and/or C# people to
determine why the program isn't terminating. There isn't anything PHP
can do about it.

I'm not trying to put you off here - but you need to solve the problem
of why your C# program isn't terminating. And that's way outside the
purpose of this newsgroup. Plus I doubt there are many who could help
you with it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 21 '08 #26

P: n/a
On 22 Jan, 00:00, Jerry Stuckle <jstuck...@attglobal.netwrote:
wart...@hotmail.com wrote:
So your hello.exe isn't terminating. *I guess you need to find out why
next. *PHPwon't continue until the exe finishes, of course.
yes, hello wolrd is not terminating. Well, hehe, why?
The custommizedphperror log doesnt show anything, and its quite
normal if it doesnt, yes.
The customized c# error log doesnt catch, execute until the end, and
doesnt report any error in the log.
The apache error log DOES NOT show anything wrong.
The windows event log DOESN NOT log error inprogram execution, sigh
The only thing I can work with right now, is the memory leak, if there
is a memory leak. I guess I have to ask in an apache group. But, I try
to ask it here also:
When starting apache, the values retrieved from windows task manager
are:
Mem usage: 16 968 K
VM size: 16 696 K
Handles: 705
After about a day, the values are:
httpd.exe
Mem usage: 58 123 K
VM size: 67 676 K
Handles: 829
Does this sound wrong?

I have no idea. *There are way more things going on in the system than
just Apache andPHP.

What you need to do is work with the MS admin and/or C# people to
determine why the program isn't terminating. *There isn't anythingPHP
can do about it.

I'm not trying to put you off here - but you need to solve the problem
of why your C# program isn't terminating. *And that's way outside the
purpose of this newsgroup. *Plus I doubt there are many who could help
you with it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Dölj citerad text -

- Visa citerad text -
I understand, you probably right. Thank you for your time.
Jan 21 '08 #27

This discussion thread is closed

Replies have been disabled for this discussion.