我想写个shell脚本挂载win2012文件共享(有权限的)的时候,让用户输入挂载的文件夹名称、账号、密码.
#! /bin/bash
echo "1. 检查网络是否正常?"
ping -c1 172.16.26.64
if [ $? -eq 0 ];then
echo "172.16.26.64网络连接正常"
else
echo "172.16.26.64网络连接断开"
exit 1
fi
clear
read -p "共享服务器文件夹名称:"
read -p "输入账号:"
read -p "输入密码:"
echo "密码:$3"
mkdir /mnt/$1
echo "ALL your input is" //172.16.26.64/$1"
mount -t cifs //172.16.26.64/$1 /mnt/$1 -o %username="$2",%passwrod="$3"
read -p "共享服务器文件夹名称:" dir
read -p "输入账号:" ac
read -p "输入密码:" pd
mkdir /mnt/$dir
echo "ALL your input is" //172.16.26.64/$dir"
mount -t cifs //172.16.26.64/$dir /mnt/$dir -o %username="$ac",%passwrod="$pd"