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