expect

Hide output from expect

放肆的年华 提交于 2019-12-03 11:16:50
问题 Here's part of an expect script #/usr/bin/expect spawn -noecho kwalletcli -f Passwords -e keyofmypassword expect ".*" set passwd $expect_out(buffer) # do some thing # ... It read password from kwalletcli, and store in variable passwd . So I can connect to the servers with this passwd . However, the output of kwalletcli is pass through expect and show on console. How can I hide that. 回答1: Try adding log_user 0 to your script. That should turn off the display to stdout. If you want to turn it

How to cross compile Expect for ARM

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How does one cross-compile Expect for ARM? It is absolutely no problem to build it from source on a host Ubuntu machine. But if you try to cross compile it, the configure script constantly gives the following error: checking if WNOHANG requires _POSIX_SOURCE... configure: error: Expect can't be cross compiled There seems to be someone who found out how to do it here (but he doesn't elaborate): https://linuxlink.timesys.com/cross_compiling_expect I also took the source and patches from here: http://repository.timesys.com/buildsources/e/expect

How to use EasyMock expect

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: The expect doesn't seem to work for me: package com . jjs . caf . library . client . drafting ; import static org . junit . Assert .*; import org . easymock . EasyMock ; import org . junit . Before ; import org . junit . Test ; import com . jjs . caf . library . client . CustomerManager ; import com . jjs . caf . library . client . UserBookLimiter ; public class DraftTest { UserBookLimiter userBookLimiter ; int expected = 5 ; @Before public void setUp () throws Exception { userBookLimiter = EasyMock . createMock ( UserBookLimiter .

Protractor - compare numbers

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: In my program I'm calculating two numbers, and I want to make sure that subtraction of them equals 1. this is the code: var firstCount = element . all ( by . repeater ( 'app in userApps' )). count (); var secondCount = element . all ( by . repeater ( 'app in userApps' )). count (); so far it's good- I'm getting the numbers. the problem comes next: var sub = secondCount - firstCount ; expect ( sub ). toEqual ( 1 ); I'm getting this error: Expected NaN to equal 1. any idea? 回答1: Both firstCount and secondCount are promises that are

What is the difference between jest.mock(module) and jest.fn()

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have tried couple different ways of defining the mock function and all of my tries failed. When I try to define it as follow: jest.mock('../src/data/server', ()=> ({server: {report: jest.fn()}})); expect(server.report.mock).toBeCalledWith(id, data, () => {...}, () => {...}); I get the this error: expect(jest.fn())[.not].toBeCalledWith() jest.fn() value must be a mock function or spy. Received: undefined If I define the mock as : var spy = jest.mock('../src/data/server', ()=> ({server: {report: jest.fn()}})); expect(spy).toBeCalledWith(id,

Ruby - Problems with Expect and Pty

旧巷老猫 提交于 2019-12-03 08:39:21
I'm trying to write a Ruby script that will ssh over to a server, run a given command, and fetch the output from it. Here's what I've got so far, mostly adapted from the Programming Ruby book: require 'pty' require 'expect' $expect_verbose = true PTY.spawn("ssh root@x.y") do |reader, writer, pid| reader.expect(/root@x.y's password:.*/) writer.puts("password") reader.expect(/.*/) writer.puts("ls -l") reader.expect(/.*/) answer = reader.gets puts "Answer = #{answer}" end Unfortunately all I'm getting back is this: Answer = .y's password: Any idea what I've done wrong and how to alleviate this?

let telnet execute single command in one line

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: hey i can login into telnet with "telnet localhost 4242" now i want to execute a single command "show network". How can i do this in one line ? something like that $ telnet localhost 4242 <- "show network" woa here the output i want 回答1: I found expect to do exactly what i want, wait for a certain output and then act upon it: expect << EOF spawn telnet localhost 4242 expect -re ".*>" send "show network\r" expect -re ".*>" send "exit\r" EOF 回答2: If you don't have to log in or anything, you can use a "here document" like this: telnet localhost

How do I use expect to connect via ssh to a system and change the password of the host system?

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am automating the process of: Connect to a system named "alpha" via ssh with password "alpha" for username "alpha". Once connected I would like to set the root password (to "kickass"). The system I am connecting to doesn't have a root password by default. I wrote this expect script to do the job but it doesn't work consistently. It works once and then if I change the password to test again, it waits at the "Enter new UNIX password:" prompt after issuing "sudo passwd root". Any ideas? #!/usr/bin/expect -f set arg1 [lindex $argv 0] set force

Spawn command not found

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an error trying to run a .sh file line 2: spawn: command not found ": no such file or directory bash.sh: line 3: expect: command not found bash.sh: line 4: send: command not found #!/usr/bin/expect -f spawn sftp -o IdentityFile=MyFile.ppk 500200243@XXX.XXX.XXX.XXX expect "XXX.XXX.XXX.XXX.gatewayEnter passphrase for key 'MyFile.ppk.ppk':" send "myPassword" Any idea why it happens? 回答1: It works OK for me (error from sftp: ssh: Could not resolve hostname XXX.XXX.XXX.XXX: Name or service not known ), though the .sh extension for an

Run expect command inside while loop in shell script

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have list of filenames in a text file,need to transfer each file into server using scp command.I am reading filenames from Read.sh and passing each file name to transfer.sh script but scp is not executing command in this transfer script.If I run transfer.sh alone with passing args its working fine. List.txt /home/kittu/file1.txt /home/kittu/file2.txt /home/kittu/file3.txt Read.sh #!/bin/bash while read p; do echo $p ./transfer.sh "$p" done <List.txt transfer.sh #!/usr/bin/expect -f # get filename from command-line set f [lindex $argv 0]