LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Php And Iptables (https://www.linuxquestions.org/questions/linux-newbie-8/php-and-iptables-439362/)

Richtown 04-27-2006 09:29 AM

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.

timmeke 04-27-2006 09:40 AM

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.

Richtown 04-27-2006 10:14 AM

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?

timmeke 04-28-2006 01:57 AM

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.


All times are GMT -5. The time now is 07:16 PM.