Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    1,963

    system commands!

    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

  2. #2
    Join Date
    Jun 2001
    Location
    Earth
    Posts
    1,259
    There are a bunch you could use. Check them out here at www.php.net. exec and system are the two that come to mind right away.

    Frank
    Umbra Hosting
    cPanel | Softaculous | CloudLinux | R1Soft | Ksplice
    Web Hosting, Reseller Hosting, VPS, Dedicated Servers, Colocation
    UmbraHosting.com

  3. #3
    Use passthru(), as exec() won't return all info.
    It's kind of fun to do the impossible.

  4. #4
    Join Date
    Aug 2002
    Location
    Plymouth
    Posts
    212
    exec() will output your data in desired file

  5. #5
    Join Date
    Feb 2001
    Location
    Pakistan Baby!
    Posts
    455
    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
    36Host.com - reliable & affordable web hosting
    * Providing Affordable Small Business Web Hosting since 2003! *

  6. #6
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    1,963
    tthx

  7. #7
    Join Date
    Feb 2001
    Location
    Pakistan Baby!
    Posts
    455
    No Problem
    36Host.com - reliable & affordable web hosting
    * Providing Affordable Small Business Web Hosting since 2003! *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •