我编写了一个ftp.exp文件,它将 C 应用程序的日志文件发送到服务器。
#!/usr/bin/expect
set timeout -1
spawn ftp xxx.xxx.xxx 21
match_max 100000
expect -re {[2]{2,}[0]{1,}}
send -- "usrxxxx"
expect -exact "usrxxxxx"
send -- "\r"
expect -re {[3]{2,}[1]{1,}}
send -- "xxxx\r"
expect -exact "\r
230 Access granted for xxxxxxxxxx !\r
Remote system type is UNIX.\r
Using binary mode to transfer files.\r
ftp> "
send -- "put /home/User/test.txt test2.txt\r"
expect -exact "put /home/User/test.txt test2.txt\r"
send -- "\r"
expect -re {[2]{2,}[6]{1,}}
send -- "quit\r"
expect eof
该脚本工作正常,但如何从C Application执行文件。