linux 脚本交互
来源:互联网 发布:linux www服务器搭建 编辑:程序博客网 时间:2024/06/03 03:18
yum install expect
首行不是 #!/bin/bash ,注意
send 密码时 后面要么加个\r,要么加个\n
#!/usr/bin/expect
spawn scp root@192.168.137.18:/dev/acq200/data/03 /data1/abc/
set timeout 3
expect "password:"
send "123456\n"
interact
更详细的:
http://www.thegeekstuff.com/2010/10/expect-examples/
http://www.thegeekstuff.com/2010/12/5-expect-script-command-line-argument-examples/
http://wenku.baidu.com/view/64eff008581b6bd97f19ea03.html
后面加不加 -f的问题 下面这个可以测试:
-c的意思是用命令行执行
expect also allows you to execute it directly in the command line using -c
echo '#! /usr/bin/expect -f
puts aaa' >flagf.exp
chmod +x flagf.exp
./flagf.exp -c 'puts 456'
输出
puts aaa' >flagf.exp
./flagf.exp -c 'puts 456'
输出
aaa
You can make the expect not interpret the command line arguments using — flag.
加了-f 会把你后面的当做参数而不是 expect的选项。
$ cat print_cmdline_args.exp#!/usr/bin/expectputs 'argv0 : [lindex $argv 0]';puts 'argv1 : [lindex $argv 1]';
While executing the above script, pass the command line options, which will be treated like an argument (instead of expect options) as shown below.
$ expect print_cmdline_args.exp -d -cargv0 : -dargv1 : -c
- linux 脚本交互
- Linux的脚本自动 交互
- Linux的脚本自动交互
- Linux的脚本自动 交互
- Linux下实现脚本的自动交互
- linux shell脚本三种交互方法
- Linux Shell脚本实现自动交互
- linux shell脚本登录远程执行命令,交互通过脚本
- 交互脚本
- 用expect编写Linux自动化交互登录脚本
- Linux基本功十一:shell脚本执行及交互
- linux下一脚本自动交互执行小例(expect)
- Linux Shell Bash 交互与非交互式脚本
- linux下通过脚本与终端交互的方法
- Django框架与linux shell 脚本无法交互问题
- Shell脚本——与Linux Shell自动交互
- Linux学习笔记:bash脚本编程之用户交互
- Linux-----Shell脚本交互实现自动输入密码
- IOS swift多点触控
- String,StringBuffer,StringBuilder的区别
- Windows时间函数
- Android系列之Fragment(一)----Fragment加载到Activity当中
- Eclipse3.4—Eclipse3.7 link方式安装插件
- linux 脚本交互
- JIRA系统部署推进上线流程
- Java学习笔记--------异常处理
- 关于软件基础中为什么使用二级指针的分析
- html5编程之用js设置背景颜色、字体颜色和行高
- poj2251
- ReactEurope Conf 参会感想
- Android Fragment 真正的完全解析(上)
- Codeforces Round #202 (Div. 2) D. Apple Tree (DFS + Math)