Stderr catch with Javascript to show progress of a running program ?

G

goldtech

Hi,

New to Javascript - mostly into server side languages but think I need
JS to do the following :

In PHP I run exec (...), so I'm doing a cmd-line program and running
it within the script. The program ( it's ffmpeg ) gives it's status
via stderr. I want a way to write status messages or progress on the
web page so the user will know how long it will take. I think I need a
client-side language like JS to do this.

How can I catch stderr and show it on the web page to a user? In
roughly real-time?

If you could link me or give me an idea of the way I will delve into
Javascript and learn how. Thanks.

Lee
 
D

Denis McMahon

How can I catch stderr and show it on the web page to a user? In
roughly real-time?

Catching the output of stderr from an exec'd server side application is
way outside the scope of javascript.
If you could link me or give me an idea of the way I will delve into
Javascript and learn how. Thanks.

Dynamically updating something on a web page on a request / response
basis can be achieved with "AJAX" (Asynchronous Javascript And XML)
using the javascript XMLHTTPRequest (xhr).

Googling something like "ajax server push" might find discussions of
techniques that can be used with ajax to emulate server side push.

Rgds

Denis McMahon
 
R

rf

goldtech said:
Hi,

New to Javascript - mostly into server side languages but think I need
JS to do the following :

In PHP I run exec (...), so I'm doing a cmd-line program and running
it within the script. The program ( it's ffmpeg ) gives it's status
via stderr.

And this program (and your PHP script) is running on the server. The client
does not yet have the page, as the server side script is still running. The
client is, well, waiting for a reponse from the server.
I want a way to write status messages or progress on the
web page so the user will know how long it will take. I think I need a
client-side language like JS to do this.

And the client side language runs where? On the client. After the server
side script has processed the request and sent it to the client and
terminated.
How can I catch stderr and show it on the web page to a user? In
roughly real-time?

You probably can't.

You could, however, provide some more information on what exactly what you
are attempting to do.
 
E

Evertjan.

Denis McMahon wrote on 09 aug 2010 in comp.lang.javascript:
Catching the output of stderr from an exec'd server side application is
way outside the scope of javascript.

Not so.

Serverside Javascript could perhaps see the result of an shell execution,
returning a specifying result in html to the client in miliseconds.
 
D

Denis McMahon

You could, however, provide some more information on what exactly what you
are attempting to do.

The impression I got was that he wants php to kick off some external
program on the server in response to a request, then send a "job in
progress" response page to the client, then update that page on the
client with progress messages in response to progress output on the
server from his external program.

He might be able to set up polls with AJAX from the client to the server
to get the progress state, if his server can handle feeding that into
php somehow, but I've never tried to call ffmpeg from php so I don't
know how easy / hard that might be.

I've also never tried to set up polling AJAX, as opposed to user driven
client side event based AJAX.

So although I think I understand broadly what he's trying to do, I have
no idea on the implementation details.

Rgds

Denis McMahon
 
R

rf

Denis McMahon said:
The impression I got was that he wants php to kick off some external
program on the server in response to a request, then send a "job in
progress" response page to the client, then update that page on the
client with progress messages in response to progress output on the
server from his external program.

From the OP:
<quote>
I think I need a
client-side language like JS to do this.
</quote>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top