1. Edit copycgi.sh, the main user to filter the files to be transmitted, as follows:
#!/bin/bash
Path= "./"
If [$#-eq 1]; Then
Path=$1
if [!-d $path]; Then
echo "Please input valid dir."
Exit
Fi
Fi
Ls-al ${path}/*.cgi|while Read Line
Todo
Filename= ' echo $line | awk ' {print $} '
#!echo "Start Send" $filename
./expect_scp_one.sh $filename
echo "Send ${filename} Finish"
Done
2. Edit the expect_scp_one.sh file, mainly used to transfer the specified file to the specified machine, the contents are as follows
#!/usr/bin/expect-f
Set passwd LogView
Set Src_path [lindex $argv 0]
Set Dst_path "logview@172.25.38.13:/usr/local/www.aaa.com/app/mpay/"
Spawn Scp-q-P $src _path $dst _path
Set Timeout 30
#expect –re ". *assword:\r"
Send "$passwd \ r"
Set Timeout 30
Send "exit\r"
Expect EOF
3. Assigning Executable Properties
chmod +x expect_scp_one.sh
chmod +x copycgi.sh
4. Test
./copycgi.sh./
Spawn Scp-q-P./mp_credit_userinfo.cgi logview@172.25.38.13:/usr/local/www.aaa.com/app/mpay/
LogView
Exit
logview@172.25.38.13 ' s Password:
Received Signal 1. (No core)
Send./mp_credit_userinfo.cgi finish