首页 > 代码库 > 〖Linux〗上传单个文件到FTP的Shell命令行(函数)

〖Linux〗上传单个文件到FTP的Shell命令行(函数)

 1 #!/bin/bash -  2 #=============================================================================== 3 # 4 #          FILE: ftp_put_file.sh 5 #  6 #         USAGE: ./ftp_put_file.sh  7 #  8 #   DESCRIPTION:  9 # 10 #       OPTIONS: ---11 #  REQUIREMENTS: ---12 #          BUGS: ---13 #         NOTES: ---14 #        AUTHOR: linkscue (scue), linkscue@gmail.com15 #  ORGANIZATION: 16 #       CREATED: 2014年08月03日 01时14分25秒 CST17 #      REVISION:  ---18 #===============================================================================19 20 # FTP上传文件21 # 依赖于 ncftp 命令22 put_action(){23     srv=$1                                      # FTP Server Addr24     port=$2                                     # FTP Server Port25     user=$3                                     # FTP Client User26     passwd=$4                                   # FTP Client Passwd27     dir=$5                                      # 文件存放目录28     file=$6                                     # 需上传的文件29     tmp=/tmp/$(basename $0)_$$.txt30     cat <<-EOF >$tmp31     cd $dir32     put $file33     bye34     EOF35     ncftp -u $user -p $passwd $srv $port <$tmp36     rm -f $tmp37 }38 39 put_action 192.168.1.201 21 scue 123 / dropbear.sh