歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

mount_win7.sh

#!/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
Copyright © Linux教程網 All Rights Reserved