海是我向往的地方,吸纳和咆哮是他的魅力!!!

shell脚本

上一篇 / 下一篇  2008-09-10 09:37:51

#! /bin/sh

    echo "输入一个要访问的合法的IP地址(如://nnn.nn.nn.nnn或者//nnn.nnn.nnn.nnn)"   
    read InputIP
case $InputIP in
   \/\/[0-9][0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9] )            
          echo "输入要访问的共享文件夹名:"
          read shfile
          smbclient $InputIP/$shfile -N -c ls
     if [ $? -eq 0 ];then
           echo "输入一个要下载的文件名:"
           read gfile
           echo "给下载的文件重新命名:"
           read pfile
           echo "$InputIP  连接成功">>msgfile
       smbclient $InputIP/$shfile -N -c 'get '$gfile'' >>msgfile 2>>msgfile
           cp $gfile $pfile
           smbclient $InputIP/$shfile -N -c 'put '$pfile''>>msgfile 2>>msgfile
           exit
     fi
           echo "\n $InputIP IP地址连接错误,或者 $shfile 共享文件夹不存在!">>msgfile;;
    \/\/[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9] )
          echo "输入要访问的共享文件夹名:"
          read shfile
          smbclient $InputIP/$shfile -N -c ls
     if [ $? -eq 0 ];then
           echo "输入一个要下载的文件名:"
           read gfile
           echo "输入修改后文件的名字:"
           read pfile
           smbclient $InputIP/$shfile -N -c 'get '$gfile'' >>msgfile 2>>msgfile
           cp $fname $filena
           smbclient $InputIP/$shfile -N -c 'put '$pfile''>>msgfile 2>>msgfile
           exit
     fi
           echo "\n $InputIP IP地址连接错误,或者 $shfile 共享文件夹不存在! ">>msgfile;;

      * ) echo "\n $InputIP IP地址不合法! \n" >>msgfile;;
esac
 

TAG:

 

评分:0

我来说两句

Open Toolbar