一段SHELL程序,名为autoftp,用vi做好后,改变权限为777,就可以运行之实现FTP的自动化了。
如下:
复制代码代码示例:
#!/bin/bash
#Filename: autoftp echo open 144.39.3.$1 >; t$1 echo user root abc >;>; t$1 echo hash >;>; t$1 echo send /tmp/test.dat /tmp/test.dat >;>; t$1 chmod 777 t$1 cat t$1 | ftp -n echo 'OK!传送结束'
代码说明:
参考示例1:
复制代码代码示例:
( echo "user root abc"
echo "bin\n" echo "cd /tmp\n" echo "lcd /tmp\n" echo "hash on" echo "put test.dat \n" echo" bye\n" )| ftp -n 144.39.3.$1 echo 'OK!传送结束'
参考示例2:
复制代码代码示例:
ftp -n 144.39.3.$1 <<!
user root abc cd /tmp bin put test.dat close bye !
参考示例3:
复制代码代码示例:
#! /bin/ksh
if [ $# = 0 ] then echo "autoftp [host|ip] [usr] [passwd] [command] [sourfile] [destfile]" else echo open $1 >; t$1 echo user $2 $3 >;>; t$1 echo hash >;>; t$1 echo bin >;>; t$1 if [ $# = 5 ] then echo $4 $5 $5 >;>; t$1 echo chmod 750 $5 >;>; t$1 else echo $4 $5 $6 >;>; t$1 echo chmod 750 $6 >;>; t$1 fi chmod 777 t$1 cat t$1 | ftp -n echo 'OK!\264\253\313\315\275\341\312\370' rm t$1 fi
参考示例4:
复制代码代码示例:
if [ $# != 1 ];then
echo "错误,请输入升级包名!!!" exit 0 fi echo "正在向各网点发送升级程序。。。" cd /ly for i in `cat w_d` do echo "向$i ......发送 \c" ftp -vin <<! open $i user root root lcd /home/ebip/tmp cd /home/cebcard/tmp put $1 bye ! echo "OK!!!发送成功" done |