Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, Any ideas how to supress error output to console for cmd like finger from a shell script. finger: connect: Connection refused finger: connect: No route to host (Any other ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    1

    How to supress Error output to console

    Hello,

    Any ideas how to supress error output to console for cmd like finger from a shell script.

    finger: connect: Connection refused
    finger: connect: No route to host

    (Any other cmd equivalent to finger , which can help finding out ip of the machine on which a particular user is logged in !!)

    Regards
    AS

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Hi,

    Redirect the output of stderr (descriptor 2) to /dev/null:

    Code:
    command 2>/dev/null
    Regards

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Yes. Do you know how to redirect normal output?

    To redirect output, we do "COMMAND > FILE". The single '>' means erase this file, while a '>>' means append to this file.

    The same applies to error redirecting, except that we need to prepend a '2'. This is because the stderr stream is stream 2.

    So for instance:
    Code:
    finger idontexist 2> /dev/null
    /dev/null is a special file that simply ignores all content. So you can write to it if you want to just dispose of input.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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