日期:2014-05-16 浏览次数:20758 次
#!/usr/local/bin/expect # 解释器声明 set timeout -1 # 设置超时时间,单位秒 #scp拷贝指令 spawn .1 expect { "*num*" { send "34\r"; exp_continue} "yes/no" { send "yes\r"; exp_continue} "*password*" {send "123456\r"} } expect eof # 模拟结束,把控制权交还控制台,如果不加这个,就等于直接退出了 #interact
#include <stdio.h> int main() { int a = 0; char password[20] = {0}; printf("please input a num:"); scanf("%d", &a); printf("this num is %d !\n", a); fflush(stdout); printf("please input a password:"); scanf("%s", password); printf("this password is %s !\n", password); return 0; }
root@192.168.200.207[root@localhost 1020]# ./cp.sh spawn ./1 please input a num:34 this num is 34 ! please input a password:34 this password is 34 ! 123456 root@192.168.200.207[root@localhost 1020]#