LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-11-2005, 10:09 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
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 ???
 
Old 12-11-2005, 10:29 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,270

Rep: Reputation: 750Reputation: 750Reputation: 750Reputation: 750Reputation: 750Reputation: 750Reputation: 750
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`;


Last edited by keefaz; 12-11-2005 at 10:30 AM.
 
Old 12-11-2005, 11:45 AM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 12-11-2005, 04:32 PM   #4
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Ok .....I could do that ....but what about the refresh every 5 sec part ?
 
Old 12-11-2005, 06:47 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 12-11-2005, 06:58 PM   #6
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
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
 
Old 12-11-2005, 08:07 PM   #7
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 12-30-2006, 01:36 PM   #8
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pipe and parse output of a command learnfast Linux - Newbie 2 06-15-2005 05:55 AM
how to pipe output from make BBB Programming 2 05-20-2005 07:14 AM
php: output the result of exec( $command ) zovres Programming 6 08-27-2004 07:41 PM
Read the output from a pipe with bash ? fluppi Linux - Software 3 01-13-2004 01:59 PM
Output truncated when using pipe tells Linux - General 1 12-16-2003 09:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration