I have a script that mounts a windows share and I worked on it to learn bash scripting.
The problem I am facing is that there is a result written in zenity as once the share is mounted it gives out OK when it fails to mount it gives out FAIL.
Now I want to ask user his password one more time if the output was FAIL so if she/he had a mistake in the password she/he can rewrite it.
Input
## define a function that launched the zenity username dialog
get_password(){
zenity --entry --width=300 --title="Mount $MOUNTDIR" --text="Password:" --hide-text
}
# attempt to get the password and exit if cancel was pressed
wPassword=$(get_password) || exit
# if the username is empty or matches only whitespace.
while [ "$(expr match "$wPassword" '.')" -lt "1" ]; do
zenity --error --title="Error in password!" --text="Please check your password! Password field can not be empty!" || exit
wPassword=$(get_password) || exit
done
Output:
# show if mounting was OK or failed
if [ $? -eq 0 ]; then
zenity --info --title="Mounting public share succeeded!" --text="Location Documents/Shares/public!"
else
zenity --error --title="Mounting public did not succeed!" --text="Please contact system administrator!"
fi
So I need the script to rerun input if output was a fail. I hope you understand what I need.
whileloop, andbreakupon success