+ -
当前位置:首页 → 问答吧 → 写了一个传递FTP的脚本,但是有点问题,请各位兄弟指点一二

写了一个传递FTP的脚本,但是有点问题,请各位兄弟指点一二

时间:2011-02-24

来源:互联网

已经建立了信任,不需要使用密码就能从A服务器直接登录 192.168.1.2,环境是SOLARIS 10


ssh2 gspnd@prodoracle
Authentication successful.
Last login: Thu Feb 24 06:56:41 2011 from 192.168.1.2


下面就是脚本

cat file.sh

#!/usr/bin/ksh

function init {
  logon=$1;shift
  file_list=$*
}

function put_file {

  bf=$1;
  log=$2;
  (/usr/local/bin/sftp2 -B $bf $logon) > $log 2>&1 &
}



function main {

  for bf in $file_list
  do
    if [ -f $bf ]; then
      log=${bf}.log
      touch $log
      if [ $? -gt 0 ];then
        error "Cannot create log file $log. The output will be discarded."
        log=/dev/null
      fi
      put_file $bf $log
    else
      error "$bf not exists. Please check and run again."
    fi
  done
}


init $*
main;

下面就是要传递文件德内容
cat put_back.txt
cd /backup/PROD
lcd /backup/UAT
mput *
quit


运行传递
./file.sh gspnd@prodoracle putback.txt
[1]     24320

但是发现文件没有被传走,在当前机器下酒产生了一个空白日志

put_back.txt.log

作者: 零七年的夏天   发布时间: 2011-02-24

UP

作者: 零七年的夏天   发布时间: 2011-02-25

热门下载

更多