expect

how to implement expect “interact” command using java

百般思念 提交于 2019-12-12 08:44:56
问题 I want to implement the expect "interact" command using java. In expect, it's possible to open an ssh session, authenticate and, then, use the "interact" command to give the control back to the user. Is that possible with java? I've tried with expectJ, expect4J and expectForJava but there's little documentation and almost no examples of how to do this. TIA. Update: for "interact" command reference, please check this out: http://wiki.tcl.tk/3914 "Interact is an Expect command which gives

Expect Scripting Logging not finishing

廉价感情. 提交于 2019-12-12 05:48:49
问题 I have an expect script that supplies configuration commands from a file to a router. I log the process to a file however expect stops writing to the log before the end of the configuration file. For instance if the config file has q r s t u v w x y z eof The log will have all the interaction up to u but the rest is not in the log but it appears the process finished all the way to z. The usual end of file comparison does not seem to work so I tried the following. set ok 0; while { $ok == 0 }

Jenkins not waiting on call to a bash script with expect

允我心安 提交于 2019-12-12 05:17:27
问题 I have a Jenkins job and on the "Execute shell" window I am calling a small application that copies files to some host. The problem is: If I run the script (shown bellow as ./relmanager ...) manually via SSH on a console to the host where Jenkins is running, everything works fine, like: [{USER}@{JENKINS_SERVER} release_manager]$ ./relmanager {USER} {PASSWD} u 2014_12_040 i 10.83.206.44 > Verifying configuration files... spawn scp -oStrictHostKeyChecking=no -C -r 2014_12_040 root@10.83.206.44:

How to capture expect output using spawn and sftp under solaris

走远了吗. 提交于 2019-12-12 04:35:59
问题 I am using expect to spawn a sftp session as follows: (lots of code snipped for clarity, and yes I understand the risks...) #!/opt/csw/bin/expect -f <snip> spawn sftp $user@$host set rez [connect $passw] if { $rez == 0 } { send "cd $location\r" set timeout -1 send "ls -l\r" send "quit\r" expect eof exit 0 } puts "\nError connecting to server: $host, user: $user and password: $passw!\n" exit 1 This works just fine. My specific question is how to I capture the results of the send "ls -l\r"

前端进阶---单元测试入门

老子叫甜甜 提交于 2019-12-12 04:08:06
什么是单元测试? 对软件中最小可测单元进行测试(如:一个方法function) 引入单元测试的原因?(一般是大的项目时) - 分模块开发,方便的定位到哪个单元出了问题 - 保证代码质量 - 驱动开发(测试驱动开发) TDD: 测试驱动开发,从需求角度看,即我需要结果是什么,如果不是就是错误的。(需求分析-》编写单元测试-》编写代码使单元测试通过-》重构) BDD: 行为驱动开发,从具体功能角度出发看,即结果应该是什么,如果不是什么就出错。(从业务角度定义目标-》找到实现目标的方法-》编写单元测试-》实现行为-》检查产品) 先写测试用例,再开发满足测试用例 测试的原则 及时修改和维护 Code review:代码审查 偶尔代码审核 同步 异步(借助工具) 只测单一的点 尽量贴近真实 避免测试中逻辑过于复杂 单元测试详解 单元测试的核心内容 测试框架 测试运行的基础 框架 Jest :基于jasmine,对react友好 jasmine :自带assert,mock Mocha :全面适合node和浏览器两个端(适合自定义高的) Qunit 出自是Query 断言库 自己对自己的断言,判断结果 工具: Chai -支持所有风格【常用】, Assert -node环境直接使用, Should,expect -用得少 Mock库 用于屏蔽其他方法的数据影响 工具: sinon Test

log_file command not logging the output of a command in Expect script

杀马特。学长 韩版系。学妹 提交于 2019-12-12 03:07:01
问题 I'm running a debug command to log the output of my command to a file.I tried the log_file command but it doesnt log the output.My code is as follows: log_file -a gdb.txt send "~/debugulator.sh $file mns20\r" log_user 0 expect -re {DSP.*0x[0-9][0-9][0-9][0-9]} log_user 1 send_log $expect_out(0,string) log_file But when I open gdb.txt,nothing is inside.Can somebody tell me where exactly am I going wrong.The version of expect I'm using is 5.26.0 UPDATE Here is the other piece of code I was

expect script regex not working

孤街浪徒 提交于 2019-12-12 02:57:05
问题 This script is failing to work as expected: #!/usr/bin/expect set timeout 2 set server [lindex $argv 0] set user [lindex $argv 1] set password [lindex $argv 2] set mac [lindex $argv 3] set interface "po1" spawn ssh $user@$server expect "Password:" send -- "$password\n" expect "*>" send "show mac address-table address $mac\n" # 100 1cc1.de65.441c dynamic ip,ipx,assigned,other Port-channel43 expect -re { (\d+) *($mac) *(dynamic|static) *(.*) *(.*)} { set interface $expect_out(5,string) expect "

Tcl Expect “interact” command echos previous output from spawned rlwrap process

六眼飞鱼酱① 提交于 2019-12-12 02:35:26
问题 I have a feeling there is something obvious I'm missing, but my searches are coming up fruitless thus far. I am trying to use a tcl/expect script to start up a tclsh interactive shell, add a procedure for easily reloading utilities for testing, and then return normal control to me. So far, the one way I've discovered to make a tcl interactive shell "usable" is to start it with "rlwrap" so that I can use arrow keys, etc. So I tried the following script and something about rlwrap is causing

how to replace a string in a file using tcl /expect

痞子三分冷 提交于 2019-12-12 01:33:19
问题 I was trying to redirect the output to a text file. It works as expected. However i would like to replace a word in the text file with a different string. I tried but it didn't work. Could you please help me with this. set output [open /scripts/cisco/output4 "a+"] for {set time 0} {$time < 3} {incr time} { for {set times 0} {$times < 3} {incr times} { log_user 0 exp_send "vmstat -n 2 5\r" puts $output $expect_out(buffer) expect "debugshell" } sleep 20 } # i used regsub to replace the the

In Tcl, seg faults from multiple threads requiring Expect

岁酱吖の 提交于 2019-12-12 01:30:05
问题 Now here's something interesting. When I have more than one thread in Tcl invoking package require Expect , I get a seg fault. e.g. package require Threads package require Expect set t [thread::create] thread::send {package require Expect} puts "blarg! Damned thing crashes before I get here" This is not a good time. Any thoughts? 回答1: Expect and Threads don't go together too well. Its the complexity you get from fork() + threads that can bite a lot there and lead to deadlocks and all kinds of