红联Linux门户
Linux帮助

Ubuntu与XP共享文件夹方式下的文件复制脚本

发布时间:2014-07-31 09:54:21来源:linux网站作者:szkbsgy

#此脚本用于在Ubuntu环境下拷贝一个文件到共享文件夹中

#contiki_Share为共享文件夹的名字

#!/bin/sh
#function:cp a file(such as xx.hex) to /mnt/hgfs/contiki_Share that is the shared directory
# between xp and vmware ubuntu
#file name: file_cp.sh
#date: 2014-07-29

#example:


#使用方法:file_cp.sh file_name

#parameter detection;检测是否为一个参数(参数为要拷贝的文件)
if [ $# -ne 1 ]
then
echo "ERROR:there mush be one parameter"
exit
fi

#dir detection;


#共享目录检测,用于检测在ubuntu是否存在共享目录,如不存在,则挂载
if [ -d /mnt/hgfs/contiki_Share ]
then
echo "dir contiki_Share exist"
else
sudo mount -t vmhgfs .host:/ /mnt/hgfs
fi

echo "$1"
sudo cp ./"$1" /mnt/hgfs/contiki_Share/
echo "$1 has been copied to /mnt/hgfs/contiki_Share/"


#注:运行脚本需要以超级用户权限运行。