How to hide "system()" output?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • opt_inf_env@yahoo.com

    How to hide "system()" output?

    Hallo,

    I want to see from php-file list of files which are in directory, where
    is the given php-file. To do so, I put in the php-file the following
    line:

    <?php $sys = system("ls") ?>

    Then I would like to work with string $sys. However, in the place where
    the "system()" is executed, php-file print on screen result of the
    execution. I would like to avoid this. Do you know how I can do it?

  • NC

    #2
    Re: How to hide &quot;system()& quot; output?

    opt_inf_...@yah oo.com wrote:[color=blue]
    >
    > I want to see from php-file list of files which are in directory,
    > where is the given php-file. To do so, I put in the php-file the
    > following line:
    >
    > <?php $sys = system("ls") ?>
    >
    > Then I would like to work with string $sys. However, in the place
    > where the "system()" is executed, php-file print on screen result
    > of the execution. I would like to avoid this. Do you know how I
    > can do it?[/color]

    $sys = `ls`;

    Note that the command is enclosed in backticks (`), not single
    quotes (').

    Also, you may want to avoid program execution calls, because
    they may not be available on your hosting service. Consider
    using opendir()/readdir() instead:



    Cheers,
    NC

    Comment

    • Andy Hassall

      #3
      Re: How to hide &quot;system()& quot; output?

      On 6 Apr 2005 13:36:15 -0700, opt_inf_env@yah oo.com wrote:
      [color=blue]
      >I want to see from php-file list of files which are in directory, where
      >is the given php-file. To do so, I put in the php-file the following
      >line:
      >
      ><?php $sys = system("ls") ?>
      >
      >Then I would like to work with string $sys. However, in the place where
      >the "system()" is executed, php-file print on screen result of the
      >execution. I would like to avoid this. Do you know how I can do it?[/color]

      In this case, use opendir() and readdir() instead.

      Or to answer the specific question, read the manual for system(), which points
      to the related function exec(). But don't use that.

      --
      Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      Working...