Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to disable php ouptut with system commands ?

    Hello

    I have to execute this shell_exec command on my scripts

    PHP Code:
    $executeonly=shell_exec("ls /etc/vmail -L -l -t"); 
    if "ls" finds not existent symlinks it reports a lot of errors like this

    no such file or directory
    no such file or directory
    no such file or directory
    no such file or directory


    Since I want hide this output , I'm trying

    PHP Code:
    ob_start();
    $executeonly=shell_exec("ls /etc/vmail -L -l -t");
    ob_end_clean(); 
    but I continue to receive

    no such file or directory
    no such file or directory
    no such file or directory
    no such file or directory

    How to hide this shell_exec output ?

    Thanks

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Maybe $executeonly=@shell_exec("ls /etc/vmail -L -l -t"); will work?

  • #3
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    You might also try appending 2>/dev/null to the command to get rid of the stderr channel

  • #4
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nothing to do , unluckly none of these solution works ... argh ..

    It's seems impossible to hide this output error

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    shell_exec() returns the output as a string, so you shouldn't be seeing anything unless you explicitly echo/print it. Post the rest of your code you're using.


  •  

    Posting Permissions

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