Professional Web Applications Themes

shell_exec problem. - PHP Development

Hi, I am using the PHP shell_exec function like this : $TmpVar=shell_exec('du -sk /mnt/MyDevice/MyFolder/*'); Even though I am supposed to get about ten lines, for some reason I ignore I only get one (one of the subfolders under MyFolder/ instead of all of them). Why is that ? Michel...

  1. #1

    Default shell_exec problem.

    Hi,

    I am using the PHP shell_exec function like this :

    $TmpVar=shell_exec('du -sk /mnt/MyDevice/MyFolder/*');

    Even though I am supposed to get about ten lines, for some reason I
    ignore I only get one (one of the subfolders under MyFolder/ instead
    of all of them).

    Why is that ?

    Michel

    Michel Guest

  2. #2

    Default Re: shell_exec problem.

    Michel Bouchet wrote: 

    Read about passthru()..

    Regards

    K
    Kleist Guest

  3. #3

    Default Re: shell_exec problem.


    Thanks for the tip,

    Unfortunately it still does not work even with passthru :

    Here are a few lines I tried, none of them work :


    1) :
    $TmpVar=exec('du -sk /mnt/MyDevice/MyFolder/* | sed
    "s/\/.*\//<\/TD><TD>/;s/^/<TR><TD>/;s/$/<\/TD><\/TR>/"');

    2) :
    $TmpVar=shell_exec('du -sk /mnt/MyDevice/MyFolder/* | sed
    "s/\/.*\//<\/TD><TD>/;s/^/<TR><TD>/;s/$/<\/TD><\/TR>/"');


    3) :
    passthru('du -sk /mnt/MyDevice/MyFolder/* | sed
    "s/\/.*\//<\/TD><TD>/;s/^/<TR><TD>/;s/$/<\/TD><\/TR>/"',$TmpVar);
    //$TmpVar=shell_exec('du -sk /mnt/MyDevice/MyFolder/*');

    I have checked the shell-command passed as argument, and it works well
    (at the command line).

    There is probably an important detail I am missing when calling it
    though shell_exec (or any other similar PHP function).

    MB


    On Tue, 26 Jul 2005 09:51:56 +0300, Kleist <pl> wrote:
     
    >
    >Read about passthru()..
    >
    >Regards
    >
    >K[/ref]

    Michel Guest

  4. #4

    Default Re: shell_exec problem.

    com (Michel Bouchet) wrote in news:42e5d181.3288859
    nnrp.gol.com:
     

    Look into using popen() and fgets() instead, this way you will get all of
    the output. If the command you're running is going to output several
    kilobytes of data, please keep this note..

    http://php.net/manual/en/function.popen.php#50408

    ...in mind.

    hth


    --

    Bulworth : PHP/MySQL/Unix | Email : str_rot13('arg');
    --------------------------|---------------------------------
    <http://www.phplabs.com/> | PHP scripts, webmaster resources
    Senator Guest

Similar Threads

  1. shell_exec sudo problem
    By Paul in forum FreeBSD
    Replies: 2
    Last Post: February 19th, 09:03 PM
  2. shell_exec question
    By Chris in forum PHP Development
    Replies: 14
    Last Post: October 9th, 04:01 AM
  3. Can't get shell_exec() to work!
    By NeoPhreak in forum PHP Development
    Replies: 5
    Last Post: September 25th, 07:18 PM
  4. [PHP] shell_exec
    By Curt Zirzow in forum PHP Development
    Replies: 0
    Last Post: August 17th, 10:49 PM
  5. [PHP] shell_exec
    By Christophe Chisogne in forum PHP Development
    Replies: 1
    Last Post: August 6th, 02:56 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139