get_file(){ HOST={ip地址} USER={用户名} PASSWORD={密码} SERVICENAME=$2 LOCAL_PATH={本地路径} REMOTE_PATH={远端路径} lftp -u $USER,$PASSWORD sftp://$HOST << EOM lcd ${LOCAL_PATH} cd ${REMOTE_PATH} mget *${SERVICENAME}* echo " success !" bye EOM } put_file(){ HOST={ip地址} USER={用户名} PASSWORD={密码} SERVICENAME=$1 LOCAL_PATH={本地路径} REMOTE_PATH={远端路径} lftp -u $USER,$PASSWORD sftp://$HOST << EOM lcd $LOCAL_PATH cd $REMOTE_PATH mput *${SERVICENAME}* bye EOM }
来源:oschina
链接:https://my.oschina.net/u/3639418/blog/4951552