scp定时传输文件脚本


-------------------------------------shell参数定义------------------------------------------

#!/bin/sh
src_file=/mcrun/cdr/stat
dest_file=/cbss/dcc01/indicators
filename=stat_sp_9001.data
bill_date=`date +%Y%m%d`
host_ip=*
username=*
password=*
echo "$host_ip"
cd /home/mcrun/public/scp_ruku
./expect_scp $host_ip $username $password $src_file $dest_file $filename $bill_date

------------------------------expect无密码传输-----------------------------

#!/usr/bin/expect
set timeout -1
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
set file_name [lindex $argv 5]
set bill_date [lindex $argv 6]
spawn scp $src_file/$file_name $username@$host:$dest_file/230\_$bill_date\_$file_name
 expect {
 "(yes/no)?"
  {
  send "yes\n"
  expect "*assword:" { send "$password\n"}
 }
 "*assword:"
{
 send "$password\n"
}
}
expect "100%"
expect eof


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM