Как можно заюзать popen...

Discussion in 'Песочница' started by FoBo$, 21 Jul 2008.

  1. FoBo$

    FoBo$ New Member

    Joined:
    14 Jul 2008
    Messages:
    142
    Likes Received:
    4
    Reputations:
    1
    Как можно заюзать popen?
    т.е. есть код вида:
    Code:
    
      $command = escapeshellcmd ($command);
      $fp = popen ('' . $command, 'r');
      if ($fp)
      {
        while (!feof ($fp))
        {
          $buf = fgets ($fp, 4096);
    ...
    ...
    ...
    
    что можно сделать имея доступ к переменной $command?
     
    #1 FoBo$, 21 Jul 2008
    Last edited: 21 Jul 2008
    1 person likes this.
  2. Dr.Z3r0

    Dr.Z3r0 Leaders of the World

    Joined:
    6 Jul 2007
    Messages:
    284
    Likes Received:
    595
    Reputations:
    567
    Собственно выполни:
    Code:
    <?php
    $command='id';//Если под никсами
    //$command='dir';//Если под виндой
    $command = escapeshellcmd ($command);
    $buf='';
    $fp=popen($command,'r');
    if($fp){
      while(!feof($fp)){
        $buf.=fgets($fp,4096);
      }
    }
    echo($buf);
    ?>
    Ход мысли ясен? ;)
     
    1 person likes this.
  3. FoBo$

    FoBo$ New Member

    Joined:
    14 Jul 2008
    Messages:
    142
    Likes Received:
    4
    Reputations:
    1
    :) спс
     
    #3 FoBo$, 22 Jul 2008
    Last edited by a moderator: 31 May 2011