Author Topic: Can i redirect any command to dev null?  (Read 309 times)

0 Members and 1 Guest are viewing this topic.

Offline postcd

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
  • Gender: Male
  • just curious
    • View Profile
    • Linux forum
    • Awards
Can i redirect any command to dev null?
« on: April 18, 2014, 02:52:19 pm »
Hello,

i have bash script and my question is if i can with peace of mind point any bash command into dev null? ( >/dev/null )

because i cant veriffy there are any errors or it really executed command. respectivelly how i can veriffy it, any advice? thx

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 13594
  • Karma: 339
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Can i redirect any command to dev null?
« Reply #1 on: April 18, 2014, 03:04:39 pm »
/dev/null is like a black hole .. anything you chuck in there will disappear never to be seen again .. it's function isn't to see if something ran "properly", that's more what clever use of exit codes (or indeed output) is for ;)

It's not really possible to give methods for testing a command or script without knowing its contents, and what you expect it to do.
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline SeZo

  • Hero Member
  • *****
  • Posts: 1505
  • Karma: 119
  • Gender: Male
    • View Profile
    • Awards
Re: Can i redirect any command to dev null?
« Reply #2 on: April 20, 2014, 11:50:47 am »
You could check if your last command executed with errors or not:
Code: [Select]
#Your Last command...
RC=$?
if [ "${RC}" -ne "0" ]; then
       # run with errors or failed
       # your debug code here
fi

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal