LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2006, 09:29 AM   #1
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Rep: Reputation: 15
Php And Iptables


hi,

<?
echo exec ("sudo ifconfig");
?>



when i run this command in php it works fine, but i want to be able to "echo" the information onto php screen?

i am not to sure how to do this? could someone shed some light please?

Rich.
 
Old 04-27-2006, 09:40 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
See
http://php.net/manual/en/function.exec.php

You need to give exec() a variable to store the output of the command.
After exec(), you can then print this variable using standard PhP echo/print functions.

The passthru() function automatically prints the output of the command.
http://php.net/manual/en/function.passthru.php

http://php.net/manual/en/ref.exec.php
contains a bunch of links to PhP commands regarding execution of programs that are external to PhP
(ie via the shell).

In short, if you're working on PhP, http://php.net is a great reference.

Last edited by timmeke; 04-27-2006 at 09:41 AM.
 
Old 04-27-2006, 10:14 AM   #3
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Original Poster
Rep: Reputation: 15
thanks,
exec(('sudo ifconfig'),$output);

This is what i have to store the array, in short do you know the command to print this array, im having trouble understanding the links?
 
Old 04-28-2006, 01:57 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I quickly looked it up on php.net.
The command is called "print" and supports arrays (ie multiline output).

For examples, open up
http://php.net in a browser and type
print
in the search box (top right on the page).
It'll take you directly to the "print" command syntax.
 
  


Reply



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
php and iptables using APACHE Richtown Linux - Newbie 13 04-22-2006 06:51 AM
PHP and IPTABLES Richtown Linux - Newbie 5 04-21-2006 03:21 AM
Running iptables from PHP Richtown Linux - Newbie 1 04-20-2006 06:52 AM
running iptables from php rookiepaul Linux - Security 20 03-29-2006 08:28 PM
php and iptables hkerssies Programming 3 10-22-2003 02:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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