Below you can find a script which mounts a share over a network to a local folder using ‘smbmount’. I prefer using ‘smbmount‘ instead of ‘mount‘ as unmounting shares executes without any pain.
The script below first asks for a password while blocking console output. You can safely put in your password without appearing it into your bash history.
#!/bin/bash echo "" echo "Provide the share password:" # Hide the console output and read the input stty_orig=`stty -g` stty -echo read adminpassword stty $stty_orig # Connect to the share on the remote server using the password echo "Connecting to remote share" smbmount /// /home/wouter/folder/ -o username=,password=$adminpassword,uid=1000,mask=000 # Show an overview of all mounted devices / shares echo "----------" mount echo "----------" echo "Done."