Questions tagged [expect]

0

votes
0

answer
6

Views

How can I use a variable in if condition in expect script?

I am executing expect script on a remote host(say A) and I want to fetch some environment variables from that remote host(A). Depending on the remote host's(A) environment variables, I would like to perform some conditional operations on that host(A) and on the host(B) from which the expect script i...
Ravi Kiran
1

votes
2

answer
85

Views

Indexing into an array using a variable in bash/expect

Simple script that does not work as expected. I have spent hours of hairpulling trying discover the right combination of escaping and quoting to make it work, but I have not yet succeeded. I have an array in K that I want to loop through from an embedded expect script. send_user '${list[4]}' works a...
Nathan
1

votes
1

answer
229

Views

ssh expect command with variables

I am planning to take password from file instead of passing parameter to the script set cmd1 {`cat passwdfile.txt | grep -w pj | cut -d';' -f5`} spawn ssh [email protected] expect 'password: ' send '$cmd1\r' expect '$ ' send 'ps -ef |grep planning1\r' expect '$ ' send 'exit\r' Error [email protected]
Naresh
1

votes
0

answer
54

Views

How to interact with unexpected ? Expect

I'm trying to get a script to get an automation. There my example script.sh: #!/bin/bash echo 'Would you like tea ?' read answer echo $answer echo 'Would you like cup ?' read answer echo $answer echo 'Would you like cake ?' read answer echo $answer echo 'Would you like car ?' read answer echo $answe...
Logicsystem360
1

votes
1

answer
381

Views

Testing Node.js API that uses Sequelize with Mocha/Expect/Supertest

I have been working on a nodejs API that works with postgres and I'm having an issue testing with expect. Sequelize is returning all fields as a string value no matter what the type is. When using .toMatchObject an error is thrown because in original object and in database id is a numeric value, bu...
Filip
1

votes
0

answer
90

Views

Script run locally but fail on Jenkins (Got SIGTERM, exiting)

I'm trying to run a script from jenkins (with using expect) - The script run correctly while I'm trying to run it from a jenkins slave locally. However, when I trigger a job to run it, the script fails and throws an error of: 11:05:47 [email protected]'s password: Got SIGTERM, exiting 11:05:47 In...
ForMartha
1

votes
1

answer
39

Views

expect multiple pass & multiple hosts

I need a script with expect, to connect & execute differents commands. The problem it's the server have differents passwords and when I try put the second pass (after the fisrt error of login) doesn't work The list of servers are inside of servers file and the passwords inside of the script #!/bin/b...
runouri
1

votes
1

answer
45

Views

Bash scripting with expect. Set parameters to multiple test boards

I'm working on a small project for school. I'm using 15 or so tuners to emulate a Cell network. I'm by no means well versed in scripting yet. I'm an EE who usually googles until I have some frankencode capable of my purposes. The goal is the set up all the modules quickly so I thought to automate th...
Garrett Gutierrez
1

votes
1

answer
300

Views

Sending file through serial port using expect and ymodem on Linux?

The ATF (arm trusted firmware, BL1, BL2) command line loop supports ymodem protocol. Under windows, I am using TeraTerm and can use its menu to manually send files to the device, using ymodem protocol, after inputting the command ymodem and seeing the C character: NOTICE: Booting Trusted Firmware...
bruin
1

votes
1

answer
79

Views

Expect script to automate FTP upload is sending corrupted file to server

#!/usr/local/bin/expect -f spawn ftp $HOSTNAME expect 'Name (sj105ut01:laureen):' send 'laureen\r' expect 'Password:' send 'password\r' expect 'ftp>' send 'cd path\r' expect 'ftp>' send 'put local_file.t.Z remote_file.t.Z' expect 'ftp>' send 'bye\n' #interact When I try to unzip the file on the ser...
loreen99
1

votes
1

answer
47

Views

Expect Script grep and awk output to be used as variable

I have looked and don't see a question quite like this one. I have an expect script that logs into remote systems and can send commands. I have a special case where I need to send a command based on the output of the previous command. I log the session of every host I log into to a file so my game p...
Jeff Cogburn
1

votes
0

answer
23

Views

expect scripts and old network gear outputs ANSI escape characters

Afternoon, I have googled this all day and even attempted other solutions in python but not had any success. I have some old-ish network gear that seems to have a weird terminal type when you SSH to them, the one where CTRL+h is backspace! This is causing problems for my expect script than needs to...
doghousedean
1

votes
1

answer
66

Views

Problem with sending commands to mikrotik through telnet using expect script

my task is to create automatic script, which send commands to mikrotik router through telnet. I am trying to create 'expect' script. But I got stuck at command sending part. Standalone login works well (first code), but when i add another command (second code), console gets stuck at password (https:...
RAJJJA
1

votes
0

answer
45

Views

Expect.pm send trims the number sign

I'm trying to use Expect.pm on an old machine with perl 5.8.8. It works but when I send a text that contains a '#' sign it is removed from the text. Is there a way to escape/protect it? Thanks Sorry corrected it is 5.8.8 #!/usr/bin/perl use Expect; use IPC::Open2; my $cmd='./rec'; my $e = Expect->ne...
user1708042
1

votes
0

answer
21

Views

How to capture a variable in expect script

I am trying to capture IP of the host on remote serial connection, so that i can ssh into the host later on. But i dont really understand how expect work, and this what i came up with so far. I tried with the posted code, but seems i cannot get the var to be the value i need, either it is empty or i...
i lovebash
1

votes
1

answer
30

Views

need help in eliminating race condition in my code

My code is running infinitely without coming out of loop. I am calling expect script from shell script, that is working fine, the problem here is script is not coming out of timout {} loop. can someone help me in this regard. spawn ssh ${USER}@${MACHINE} set timeout 10 expect 'Password: ' send -s '$...
umer
1

votes
1

answer
1.2k

Views

Getting Expect to interact until the program terminates

I am using the Expect Linux tool and I have to interact with the shell. However, it's not a true interact, I just want to see what's going on. How can I get Expect to exit after the interacting program exits?
Malfist
1

votes
1

answer
689

Views

expect replacement

I want to work with a modem interfaced on a serial port on an embedded platform. Here are some solutions I have rejected so far : Expect plus a terminal program : My (cross)build system does not have any package rules for expect, and according to the installation instructions from the expect source...
shodanex
1

votes
2

answer
5.3k

Views

Regular Expression to find string in Expect buffer

I'm trying to find a regex that works to match a string of escape characters (an Expect response, see this question) and a six digit number (with alpha-numeric first character). Here's the whole string I need to identify: \r\n\u001b[1;14HX76196 Ultimately I need to extract the string: X76196 Here'...
jjclarkson
1

votes
3

answer
741

Views

sh/expect/sudo/screen all needed together in one command

What I need to have happen: PHP needs to launch an server app which has root permissions running in the background. All of this should be silent. -Sudo is needed to allow php to perform an op that requires root permissions. -Screen is required to allow the app to run outside the scope of the webpage...
conartist6
1

votes
1

answer
224

Views

Ruby version of the TCL-based Expect? [closed]

Expect seems to be a very powerful automation tool: http://www.nist.gov/mel/msid/expect.cfm Is there a Ruby equivalent to that tool?
never_had_a_name
1

votes
1

answer
592

Views

automate operations within a Virtualbox machine

I'm Having some trouble in a vm that seems to occur only once in a hundred during shutdown/reboot. To help the debug, I'm thinking to write a script that runs on my desktop, which starts the vm and automate operations for a huge number of times (keyboard key pressed) whithin it. (VirtualBox preferre...
samb
1

votes
1

answer
944

Views

linux expect command

I am using the linux 'expect' to automate passwords. #!/usr/bin/expect set password passwd spawn scp * [email protected]_address:. expect 'password:' send '$password\r' expect eof output : spawn scp * [email protected]_address:. [email protected]_address's password: *: No such file or directory Looks like the regular expres...
Sachin Shetye
1

votes
2

answer
8.2k

Views

ssh expect script

I have this expect script which called by another script to log cisco devices. some reason become become slow to log to cisco devices. is there any one can see any problem or suggestion may increase the speed for this script. thanks in advance #!/usr/bin/expect log_user 0 set timeout 10 set userid...
dan
1

votes
2

answer
338

Views

Is there a way to use Expect-Lite variables inside of a spawned command?

I've been working on trying to automate the complicated process of building source code on a build machine and then transferring the compiled image files over to my embedded ARMv7 device to be flashed. Each step by itself is easy to automate with standard Linux Shell Script, but when trying to do e...
Drellgor
1

votes
3

answer
4.4k

Views

Send input to running shell script from bash

I'm writing a test suite for my app and using a bash script to check that the test suite output matches the expected output. Here is a section of the script: for filename in test/*.bcs ; do ./BCSC $filename > /dev/null NUMBER=`echo '$filename' | awk -F'[./]' '{print $2}'` gcc -g -m32 -mstackrealign...
Kevin Burke
1

votes
1

answer
551

Views

Using a child process to keep a SSH pseudo-tty-less connection open in Ruby

I want to create a Ruby script which opens a SSH pseudo-tty-less connection, and keeps it open. I also want to send it the password with help of e.g. expect. I have tried this: (I have removed servername, password and username) #!/usr/bin/env ruby require 'pty' require 'expect' username = 'USERNAME'...
Mads Ohm Larsen
1

votes
2

answer
495

Views

spawning Ruby IRB with Tcl Expect ends tragically in a broken pipe!

I am simply trying to open an irb window and enter commands. This used to work but somehow now it is broken: package require Expect set exp::winnt_debug 1 set errorInfo set SPAWN_ID '' set EXPECT_TIMEOUT 20 set PROMPT {irb.*[*'>] } set RUBY_HOME 'C:/ruby/' exp_spawn [file join $RUBY_HOME 'bin' 'ruby...
Tom
1

votes
1

answer
2.2k

Views

Is it possible to continue execution even if “expect” does not match anything

Is there a way with expect interpreter to say something like expect { 'keyword1' {send 'action1'} 'keyword2' {send 'action2'} unpredicted stuff {send 'action3'} }
Eedoh
1

votes
1

answer
1.5k

Views

Executing expect script from php. Can't get the stty settings right

I've got a php script that executes an expect script. Expect scipt connects remotely over telnet to another device, executes a couple of commands there and returns results. Php script is just a way to output the results returned by the remote device on a web page. This is a line I have problems with...
facha
1

votes
2

answer
365

Views

Expect automating login to second level remote machine

I need to login to one development server to put things on live server. So processor is like this Login to development server. Fire Deploy Script Deploy script asks for 3 password. Followed by ssh pass-phrase password. I don't have any other access on development and live server. So I can't used...
Vivek Goel
1

votes
1

answer
746

Views

Linux expect command analog

While developing a shell script to copy logs from lots of remote servers, I found out a problem that I need to pass a password for each ssh connection to each server (and it makes me very nervous:) ). I know that it is better to use keys, but the process of adding them will take a lot of time due to...
user253202
1

votes
2

answer
4.1k

Views

Modify expect-based SSH script to work on machines that don't require a password

The following expect script works fine when the Linux machine asks for a password after login. But some of our Linux machines don't need a password for SSH (we can login without a password), so I need to change the expect script in order to support machines without a password. How can I do that? $ e...
1

votes
1

answer
76

Views

StringToBytes Issue in Expect Script

I am using the below command in my Expect script file. set name [StringToBytes 'Tamin']; puts 'name = $name' When i run this script, i get the below error. invalid command name 'StringToBytes' while executing 'StringToBytes 'Tamin'' invoked from within 'set name [StringToBytes 'Tamin']' Can anyone p...
Tamin
1

votes
4

answer
1.6k

Views

How can I use expect to reply to an SSH login prompt?

I need to create an autologin script for an ssh mount I have created in fstab. I know that you should use secure key authentication to do this but in this case it is not possible as the server does not allow it so I need to create a bash script to enter the password when prompted. I have tried with...
reptilian
1

votes
1

answer
1.5k

Views

ActiveTCL - Unable to run a batch file from an Expect Script

I was originally trying to run an executable (tftpd32.exe) from Expect with the following command, but for some unknown reason it would hanged the entire script: exec c:/tftpd32.351/tftpd32.exe So, decided to call a batch file that will start the executable. I tried to call the batch file with the f...
atomicluis
1

votes
1

answer
2.2k

Views

TCL / Expect Scripting - Using a conditional statement to attempt a secondary login password

I am very close to finish a TCL/TK app that logs into a Cisco Access Point via a serial connection (RS232} and gives it an IP address (very basic) However, I would like my script to attempt a secondary password if the first one fails This is how the Cisco CLI behaves with a serial connection when th...
atomicluis
1

votes
1

answer
387

Views

Send command while expect can get specific text

I Have one problem when i am using expect. I need to list some information. But the program list 10 items and then shows (More...) and waits a key So: expect 'More...' send '\n' But the program shows more 10 lines and does it again, i can track how many times i need to do that, but the list changes...
Lefsler
1

votes
1

answer
535

Views

Using Expect with an ant build file

I have a command line program and I'm trying to automate interaction with that program using Expect. The program is launch by the running the command 'ant runconsole' on the build file. I also embedded the Expect script in a bash script. Currently my code looks like: #!/bin/bash cd $HOME/myProj/bu...
E T
1

votes
2

answer
1.1k

Views

How long does a expect/tcl script execute

I have written a telnet script to remote control a cisco switch, and it takes me about 2-3 minitus to get start, even though i write a short script with a single proc, it also take 2-3 minutes to start. The proc is as below. proc test_proc {} { puts '123' } test_proc Is anybody who has faced this no...
user1648364

View additional questions