473,417 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

exec php

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
26 3614
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hal Vaughan | last post by:
I have a script used to find and run Java on a Windows system.  It worked fine on original tests (on a Windows XP system).  It's now running on a Windows 2000 (sp3) system, and it won't work -- the...
1
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
5
by: TPJ | last post by:
I have the following code: ----------------------------------- def f(): def g(): a = 'a' # marked line 1 exec 'a = "b"' in globals(), locals() print "g: a =", a
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
2
by: xml0x1a | last post by:
How do I use exec? Python 2.4.3 ---- from math import * G = 1 def d(): L = 1 exec "def f(x): return L + log(G) " in globals(), locals() f(1)
23
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.