Web Hosting Talk







View Full Version : system commands!


clocker1996
08-25-2002, 07:00 AM
Hi,

this is piss easy

does anyone know how you would run a system command and output it on the .php file ?

e.g. if i wanted to run 'w' how would i do that?

here is an example in perl
http://drirc.net/monitor/sys.pl

this would be for linux

ffeingol
08-25-2002, 07:55 AM
There are a bunch you could use. Check them out here (http://www.php.net/manual/en/ref.exec.php) at www.php.net. exec and system are the two that come to mind right away.

Frank

AlCapone_yg
08-25-2002, 08:42 AM
Use passthru(), as exec() won't return all info.

combs
08-25-2002, 10:33 AM
exec() will output your data in desired file

Omair Haroon
08-25-2002, 11:45 AM
Use backtick function in PHP. Here is a quote from the PHP Manual:


PHP supports one execution operator: backticks (``). Note that these are not single-quotes! PHP will attempt to execute the contents of the backticks as a shell command; the output will be returned (i.e., it won't simply be dumped to output; it can be assigned to a variable).


$output = `ls -al`;
echo "<pre>$output</pre>";



Drop me a PM if you need any help regarding this or any other function.

--Omair

clocker1996
08-25-2002, 11:52 AM
tthx

Omair Haroon
08-25-2002, 11:55 AM
No Problem :)