-------------------------------------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