Cmd in PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mirainc
    New Member
    • Jul 2008
    • 34

    Cmd in PHP?

    Was wondering if i could run a cmd command in php. I want to display the PC's system information. i know that in cmd it is C:\>systeminfo. So how can i get that in PHP. Must use shell_exec()? really lost on how to do this. this is wad i have been trying but no success.

    [PHP]<?php
    $cmd = 'C:\>systeminfo ';
    $display = .shell_exec($cm d);
    echo "$display";
    ?>[/PHP]

    [PHP]<?php
    $output = shell_exec('sys teminfo');
    echo "<pre>$outp ut</pre>";
    ?>[/PHP]

    Any help is greatly appreciated!! (:
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Mirainc.

    If you're getting no output, the command is probably generating an error (perhaps a permission denied error?).

    If you run that command in a DOS prompt, do you get the proper output?

    Comment

    • samatair
      New Member
      • Nov 2007
      • 61

      #3
      [PHP]
      <?php
      $output = shell_exec('sys teminfo');
      echo "<pre>$outp ut</pre>";
      ?>
      [/PHP]

      I tried in my Windows XP system and was able to generate the output.
      I am using XAMP to run php.

      But not sure what is the case with you. I wish your problem be solved.

      Comment

      • mirainc
        New Member
        • Jul 2008
        • 34

        #4
        Originally posted by pbmods
        Heya, Mirainc.

        If you're getting no output, the command is probably generating an error (perhaps a permission denied error?).

        If you run that command in a DOS prompt, do you get the proper output?
        Oh.. when i run in cmd i get the output but when i run my php page the whole page will not load.. it just hangs..Still donno wadt the problem is.. i manage to do a ping in a similar way n display the output but the system info is still giving me problems.

        Comment

        • mirainc
          New Member
          • Jul 2008
          • 34

          #5
          Originally posted by samatair
          [PHP]
          <?php
          $output = shell_exec('sys teminfo');
          echo "<pre>$outp ut</pre>";
          ?>
          [/PHP]

          I tried in my Windows XP system and was able to generate the output.
          I am using XAMP to run php.

          But not sure what is the case with you. I wish your problem be solved.

          hmm.. i don know what XAMP is.. sorry... i'm new to this.. (: I donno if this will help but i'm using apache to run my php.

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            Originally posted by mirainc
            hmm.. i don know what XAMP is.. sorry... i'm new to this.. (: I donno if this will help but i'm using apache to run my php.
            Hi.

            Did you try samatair's code?
            It worked for me on Vista.

            Comment

            • mirainc
              New Member
              • Jul 2008
              • 34

              #7
              Oh awesome! it finally worked! thanks everyone.. Weird that it actually worked now.. considering that i was using the same codes..

              Thanks all who helped!

              Comment

              Working...