Loading ...
Sorry, an error occurred while loading the content.

Command line output capture in php

Expand Messages
  • muhammad
    I need to capture windows command output in php scripts. such as ... output: SerialNumber CNU1284N9Y Please provide script for capturing output
    Message 1 of 2 , Jun 4, 2012
    View Source
    • 0 Attachment
      I need to capture windows command output in php scripts.


      such as
      >wmic bios get SerialNumber

      output:
      SerialNumber
      CNU1284N9Y


      Please provide script for capturing output
    • Mamnun
      The function you need is shell_execfor example: or in your case:
      Message 2 of 2 , Jun 5, 2012
      View Source
      • 0 Attachment
        The function you need is shell_exec
        for example:
        <?php
        $output 
        shell_exec('ls -lart');
        echo 
        "<pre>$output</pre>";
        ?> 

        or in your case:
        <?php
        $output = shell_exec('wmic bios get SerialNumber');
        echo "<pre>$output</pre>";
        ?>


        be carefull of where you are executing the command(windows/linux) and also, shell_exec may be disabled in php safemode.

        Hope this helps.

        Regards,
        Mamnun

        --- In phpexperts@yahoogroups.com, "muhammad" <zunaid2005@...> wrote:
        >
        > I need to capture windows command output in php scripts.
        >
        >
        > such as
        > >wmic bios get SerialNumber
        >
        > output:
        > SerialNumber
        > CNU1284N9Y
        >
        >
        > Please provide script for capturing output
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.