LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Pipe output of command to php !!! (https://www.linuxquestions.org/questions/programming-9/pipe-output-of-command-to-php-391505/)

ALInux 12-11-2005 09:09 AM

Pipe output of command to php !!!
 
HI Iam trying to achieve the following through PHP:

1-Execute: jettop -i eth0 (no prob here)
2-Display the output in text area: (no prob here)
3-Refresh every 10 seconds (PLEASE HELP)
4-Close jettop when closed ( PLEASE HELP)

But the main problem is the following:
If the windows gets refreshed every 5 secs then the jettop program which is a network sniffer will be executed every 5 secs ...so it must be killed everytime the window is refreshed.
Or "and that is what Iam aiming for" I want to pipe the output of jettop to a php script and every 10 seconds I want to display the latest about that output and when the window is closed I want to close jettop.

Any hints ideas ...tricks ???

keefaz 12-11-2005 09:29 AM

You could use a variable in session or cookie which
indicate if jettop is already started.

something like :
PHP Code:

session_start();

if(!isset(
$_SESSION['jettop_is_started'])) {
    
/* first lauch, jettop is not started yet */
    /*...
      code to start jettop
      ...
    */
    
$_SESSION['jettop_is_started'] = true;
}

if(
$I_want_stop_jettop_now) {
    
/* if you want to stop jettop */
    
`killall jettop`;



graemef 12-11-2005 10:45 AM

You will probably want to look at JavaScript to manage the "when a window is closed then close jetop" requirement. I'd suggest that you look at Ajax which can also manage the updating of your data without having to resend the entire page all the time. Sorry but I've no experience with Ajax - it's on my evergrowing list of things to learn next!

all the best.

graeme.

ALInux 12-11-2005 03:32 PM

Ok .....I could do that ....but what about the refresh every 5 sec part ?

graemef 12-11-2005 05:47 PM

Yes that is really what Ajax is all about see the "Filtering and involved data manipulation" at http://www.sourcelabs.com/blogs/ajb/..._use_ajax.html

all the best.

graeme.

ALInux 12-11-2005 05:58 PM

Thanks Graemef for your concern...Ive checked the link and Ajax seems to be promising...but you have to know that Iam new to PHP...and I do not know about javascript alot (else then using a few functions and that it is client based)...so is there a way to do the job in PHP instead ( in addition to what keefaz said)...I dont want to tap into a new thing right now

graemef 12-11-2005 07:07 PM

I which case I'd suggest that you hold off implementing it with Ajax but that you keep it at the back of your mind so that in the future when you feel more comfortable with php & javascript you can revisit it.

graeme.

ALInux 12-30-2006 12:36 PM

Hi
I was reading through my old posts..and I must say that Iam using AJAX right now to solve similar issues i should have used it straightaway at that time.


All times are GMT -5. The time now is 10:43 AM.