expect

Tcl Expect fails spawning SSH to server but SSH from command line works

夙愿已清 提交于 2020-01-25 12:12:10
问题 I have some code that I'm using to connect to a server and perform some commands. The code is as follows: #!/usr/bin/expect log_file ./log_std.log proc setPassword {oldPass newPass} { send -- "passwd\r" expect "* Old password:" send -- "$oldPass\r" expect "* New password:" send -- "$newPass\r" expect "* new password again:" send -- "$newPass\r" } set server [lindex $argv 0] spawn /bin/ssh perfgen@$server # Increase buffer size to support large text responses match_max 100000 # Conditionally

Tcl Expect fails spawning SSH to server but SSH from command line works

﹥>﹥吖頭↗ 提交于 2020-01-25 12:11:46
问题 I have some code that I'm using to connect to a server and perform some commands. The code is as follows: #!/usr/bin/expect log_file ./log_std.log proc setPassword {oldPass newPass} { send -- "passwd\r" expect "* Old password:" send -- "$oldPass\r" expect "* New password:" send -- "$newPass\r" expect "* new password again:" send -- "$newPass\r" } set server [lindex $argv 0] spawn /bin/ssh perfgen@$server # Increase buffer size to support large text responses match_max 100000 # Conditionally

TCL_REGEXP::How to grep 5 diifferent words from a variable using TCL regexp. And how to send greeped output to each column of excel sheet?

江枫思渺然 提交于 2020-01-25 00:19:26
问题 My TCL script: set line { Jul 24 21:06:40 2014: %AUTH-6-INFO: login[1765]: user 'admin' on 'pts/1' logged Jul 24 21:05:15 2014: %DATAPLANE-5-: Unrecognized HTTP URL www.58.net. Flow: 0x2 Jul 24 21:04:39 2014: %DATAPLANE-5-: Unrecognized HTTP URL static.58.com. Flow: Jul 24 21:04:38 2014: %DATAPLANE-5-: Unrecognized HTTP URL www.google-analytics. com. Flow: 0x2265394048. Jul 24 21:04:36 2014: %DATAPLANE-5-: Unrecognized HTTP URL track.58.co.in. Flow: 0 Jul 24 21:04:38 2014: %DATAPLANE-5-

How to start a shell script within “expect script”?

牧云@^-^@ 提交于 2020-01-24 09:03:40
问题 In this expect script there will be no ssh server connected, I just want to execute a ".sh" file locally, is that possible? For instance: #!/bin/expect command "xxx.sh" # a command which starts a certain shell script Also, is it possible to execute a expect script within a expect script? For instance: #!/bin/expect command "xxx.exp" # a command which starts a certain expect script Any help? 回答1: The command in Expect to run a shell command is spawn . #!/bin/expect spawn command arg1 arg2 ...

Tests

折月煮酒 提交于 2020-01-23 03:49:10
// 检查格式 pm.test("response 应该包含 code,data,message", function () { pm.expect(pm.response.text()).to.include("code"); pm.expect(pm.response.text()).to.include("data"); pm.expect(pm.response.text()).to.include("message"); }); // 检查目标数据类型 var jsonData = pm.response.json().data.info; pm.test("列表", function () { pm.expect(pm.response.json().data.status === 0).to.be.eql(true) pm.test("data 应该是数组", function () { pm.expect(Array.isArray(jsonData)).to.be.eql(true) }); }); // 检查目标数据类型-获取数据 var jsonData = pm.response.json().data.list; // 设置文件夹id环境变量给下一个接口测试使用 pm.environment.set("noticeId", jsonData[0].id);

allure的其他参数

烈酒焚心 提交于 2020-01-21 23:28:03
import pytestimport requestsimport allure l = [ { "url": "https://www.v2ex.com/api/site/info.json", "title":"v2ex的title", "desc":"v2ex的描述信息", "expect": {"title": "V2EX","slogan1111":"way to explore","domain":"www.v2ex.com"} }, { "url": "https://cnodejs.org/api/vl/topics", "title":"cnodejs的title", "desc":"cnodejs的描述", "expect": {"success": True}},]@pytest.mark.parametrize("d", l)def test_case(d): #allure的动态参数 dynamic allure.dynamic.title(d["title"]) allure.dynamic.description(d["desc"]) response = requests.get(url=d["url"]).json() for k in d["expect"]: print(333333,k) if d["expect"][k] !=

用expect做自动应答脚本

安稳与你 提交于 2020-01-20 18:35:47
Expect是一个用来实现自动交互功能的软件套件 (Expect [is a] software suite for automating interactive tools)。使用它系统管理员可以创建脚本用来实现对命令或程序提供输入,而这些命令和程序是期望从终端(terminal)得到输入,一般来说这些输入都需要手工输入进行的。 Expect则可以根据程序的提示模拟标准输入提供给程序需要的输入来实现交互程序执行。 需要安装expect、tcl包: yum install expect tcl 示例脚本: 1 #!/usr/bin/expect、 2 set timeout 10 3 set username [lindex $argv 0] 4 set password [lindex $argv 1] 5 set host [lindex $argv 2] 6 spawn ssh $username@$host 7 expect "assword:" 8 send "$password\r" 9 expect "#" 10 send "touch a.txt\r" 11 send "touch b.txt\r" 12 send "touch c.txt\r" 13 send "touch d.txt\r" 14 send "exit\r" 15 expect eof 16

Expect script for checking ssh connection for a list of ips

淺唱寂寞╮ 提交于 2020-01-17 05:20:07
问题 Can anyone help me in creating an expect script to just do an SSH on a list of servers and check if it was fine. I do not need to interact, do not need to fire any command on each server, I just want to do an ssh and come out, with a return code mentioning whether it was successful or not. Expect is important here, as I do not have an option to setup a passwordless connection. Also there is a possibility that passwordless connection is setup on some of those servers. I tried something like: #

How to read stdout from a FILE* created with libexpect in C++ on linux?

不问归期 提交于 2020-01-16 08:23:09
问题 Using C++ I created a FILE* using libexpect: FILE* fd = exp_popen("ssh root@sunblaze"); I got to the command line using: exp_fexpectl(fp , exp_exact , "password: " , 1 , exp_end); Now the other posses in bash shell and I want to get the contents of a file there, so I have to run the command cat /port1/port and get all it prints in a char buffer. How do I do that? fgets doesn't seem to work... Thanks in advance 回答1: Assuming that your machine and "sunblaze" are within a firewalled off,