Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while true
- do
- read -s -p "Enter root password: " rootpass1
- echo
- read -s -p "Enter root password again: " rootpass2
- echo
- if [[-z "$rootpass1"] && [-z "$rootpass2"]]
- then
- echo "Password will not be changed"
- break
- else
- if [ $rootpass1 != $rootpass2 ]
- then
- echo "Passwords are not identical"
- else
- echo "user:$rootpass1" | chpasswd
- break
- fi
- fi
- done
- script.sh: line 8: [: missing `]'
- #!/bin/bash
- read -s -p "Enter root password: " rootpass1
- echo
- read -s -p "Enter root password again: " rootpass2
- echo
- if [[ -z "$rootpass1" && -z "$rootpass2" ]]
- then
- echo "Password will not be changed"
- else
- if [[ "$rootpass1" != "$rootpass2" ]]
- then
- echo "Passwords are not identical"
- else
- echo "user:$rootpass1" | chpasswd
- fi
- fi
- if [[ -z "$rootpass1" ]] && [[ -z "$rootpass2" ]]
- #!/bin/bash
- while true
- do
- read -s -p "Enter admin password: " rootpass1
- echo
- read -s -p "Enter admin password again: " rootpass2
- echo
- if [[ -z "$rootpass1" ]] && [[ -z "$rootpass2" ]]
- then
- echo "Password will not be changed. Both are empty."
- echo
- break
- else
- if [[ $rootpass1 != $rootpass2 ]]
- then
- echo "Passwords are not identical. Try again."
- echo
- else
- echo "root:$rootpass1" | chpasswd
- echo "Password changed."
- echo
- break
- fi
- fi
- done
Add Comment
Please, Sign In to add comment