Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #!/bin/bash
  2. while true
  3. do
  4. read -s -p "Enter root password: " rootpass1
  5. echo
  6. read -s -p "Enter root password again: " rootpass2
  7. echo
  8. if [[-z "$rootpass1"] && [-z "$rootpass2"]]
  9. then
  10. echo "Password will not be changed"
  11. break
  12. else
  13. if [ $rootpass1 != $rootpass2 ]
  14. then
  15. echo "Passwords are not identical"
  16. else
  17. echo "user:$rootpass1" | chpasswd
  18. break
  19. fi
  20. fi
  21. done
  22.  
  23. script.sh: line 8: [: missing `]'
  24.  
  25. #!/bin/bash
  26. read -s -p "Enter root password: " rootpass1
  27. echo
  28. read -s -p "Enter root password again: " rootpass2
  29. echo
  30.  
  31. if [[ -z "$rootpass1" && -z "$rootpass2" ]]
  32. then
  33. echo "Password will not be changed"
  34. else
  35. if [[ "$rootpass1" != "$rootpass2" ]]
  36. then
  37. echo "Passwords are not identical"
  38. else
  39. echo "user:$rootpass1" | chpasswd
  40. fi
  41. fi
  42.  
  43. if [[ -z "$rootpass1" ]] && [[ -z "$rootpass2" ]]
  44.  
  45. #!/bin/bash
  46. while true
  47. do
  48. read -s -p "Enter admin password: " rootpass1
  49. echo
  50. read -s -p "Enter admin password again: " rootpass2
  51. echo
  52. if [[ -z "$rootpass1" ]] && [[ -z "$rootpass2" ]]
  53. then
  54. echo "Password will not be changed. Both are empty."
  55. echo
  56. break
  57. else
  58. if [[ $rootpass1 != $rootpass2 ]]
  59. then
  60. echo "Passwords are not identical. Try again."
  61. echo
  62. else
  63. echo "root:$rootpass1" | chpasswd
  64. echo "Password changed."
  65. echo
  66. break
  67. fi
  68. fi
  69. done
Add Comment
Please, Sign In to add comment