Posted By

ksaver on 08/22/10


Tagged

Bash unix scripts dependences


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

naesk


check_deps.sh


 / Published in: Bash
 

URL: http://pastebin.com/2b1t7MtU

  1. # snippet: check_deps.sh
  2. # version: 0.02 :-)
  3. # author: ksaver (at identi.ca)
  4. # license: Public Domain
  5. # arguments: List of dependences to check.
  6. # sets: check_deps function
  7. # returns: 0=OK, 1=ERR and echoes a helpfull message :-)
  8. # usage: Use into a script:
  9. # source check_deps.sh
  10. # check_deps 'wget curl ftp tor mplayer or whatever'
  11.  
  12. function _dep_error()
  13. {
  14. # for internal use only
  15. echo "[ERR]: Dependence '$1' Not found in your path!"
  16. }
  17.  
  18. function check_deps()
  19. {
  20. for DEPEND in $@
  21. do
  22. /usr/bin/which $DEPEND &> /dev/null || (__dep_error $DEPEND && return 1)
  23. done
  24. }

Report this snippet  

You need to login to post a comment.