Guest User

Untitled

a guest
Dec 28th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. test1=`sed -i "/:@/c connection.url=jdbc:oracle:thin:@$ip:1521:$dataBase" $search`
  2. valid $test1
  3.  
  4. function valid () {
  5. if $test -eq 1; then
  6. echo "OK"
  7. else echo "ERROR"
  8. fi
  9. }
  10.  
  11. some_command
  12. if [ $? -eq 0 ]; then
  13. echo OK
  14. else
  15. echo FAIL
  16. fi
  17.  
  18. some_command
  19. retval=$?
  20. do_something $retval
  21. if [ $retval -ne 0 ]; then
  22. echo "Return code was not zero but $retval"
  23. fi
  24.  
  25. if some_command; then
  26. printf 'some_command succeededn'
  27. else
  28. printf 'some_command failedn'
  29. fi
  30.  
  31. if output=$(some_command); then
  32. printf 'some_command succeded, the output was «%s»n' "$output"
  33. fi
  34.  
  35. command && echo OK || echo Failed
  36.  
  37. cd /nonexistant
  38. if [ $? -ne 0 ]
  39. then
  40. echo failed
  41. else
  42. echo success!
  43. fi
  44.  
  45. command && echo $? || echo $?
  46.  
  47. $ find . -name "not_existing_file"
  48. $ echo $?
  49. 0
  50. $ file ./not_existing_file
  51. ./not_existing_file: cannot open `./not_existing_file' (No such file or directory)
  52. $ echo $?
  53. 0
  54.  
  55. $ file ./doesntexist | while IFS= read -r output; do
  56. > case "$output" in
  57. > *"No such file or directory"*) printf "%sn" "This will show up if failed";;
  58. > *) printf "%sn" "This will show up if succeeded" ;;
  59. > esac
  60. > done
  61. This will show up if failed
  62.  
  63. $ find . -name "doesn'texist" | if ! read IFS= out; then echo "File not found"; fi
  64. File not found
  65.  
  66. error="$([COMMAND] $1 2>&1 >/dev/null)"
  67.  
  68. if [ $? -ne 0 ]; then
  69. echo "[THIS-FUNCTION]: $error"
  70. exit 1
  71. fi
Add Comment
Please, Sign In to add comment