#!/bin/ksh
# Make sure only root can run our script.
if [ "$(id -u)" != "0" ]; then
echo "This script. must be run as root" 1>&2
exit 1
fi
my_windows="135.251.27.66"
# /dev/null means no output in screen
# &2 means stderr
ping -c 1 -W 2 $my_windows >> /dev/null || { echo "fail, need CSL authentication" >&2; exit 1; }
#echo "have connected my windows ......"
#find mount files
mount_files=`echo "$(mount)"|awk '{print $3}'`
win_mnt=/mnt/huimingf/code
my_mnt=""
check_winmnt()
{
for my_mnt in ${mount_files[@]}
do
if [ "$my_mnt" == "$win_mnt" ]
then
return 0;
fi
done
return 1;
}
check_winmnt;
#function return $? just like the shell return
if [ $? == 0 ]
then
echo "$my_mnt have mount "
else
echo "mount the $win_mnt"
mount -t cifs -o username='AD4/huimingf' -o uid=25623,gid=1830, //135.251.27.66/code /mnt/huimingf/code
fi
exit 0
mount_win7.sh
最新推荐文章于 2025-06-17 18:21:00 发布
本文介绍了一个Shell脚本,该脚本首先确保仅由root用户运行,并检查到特定Windows系统的连接状态。若连接失败,则尝试进行CSL认证。成功后,检查特定路径是否已挂载,如未挂载则进行挂载操作。
1313

被折叠的 条评论
为什么被折叠?



