2,791 questions
-2
votes
1
answer
43
views
How to automate cli interactions with gh copilot using expect
I want to automatically press
Enter (select generic shell command)
Enter (Copy command to clipboard)
Up (Move cursor to Exit)
Enter (Exit gh cli)
so I can Ctrl+V to paste the suggested terminal ...
0
votes
3
answers
99
views
Expect module: end of string is correctly matched, but characters remain in 'after' part, causing next expect to continue prematurely [closed]
I am writing a Perl script with the Expect module, where sometimes expects continues too early, because it matches a prompt of a previous command's output.
To illustrate the problem, I created a ...
2
votes
2
answers
93
views
Automate debug java with rlwrap
I use rlwrap to debug a Java process
rlwrap jdb -attach 192.168.5.55:9999
When the breakpoint stop:
> stop in comm.app.aaa.func
> set a = 0
> cont
I do that few times, each time the ...
0
votes
2
answers
69
views
expect: make two python scripts communicate
I want to have two scripts communicating by exchanging messages. I have to use pexpect because of other restrictions. I am trying to make a minimal working example before I build it out for my ...
0
votes
2
answers
61
views
What is the "normal" way to implement include guards in TCL?
There are a variety of ways I could implement include guards in TCL, but this is probably the most robust way I've considered, without knowing any tricks or shortcuts:
if { ! [info exists _THIS_FILE_] ...
0
votes
1
answer
56
views
How can I correct the encoding of the interactive output in my Expect/Tcl script?
I'm writing an expect script which processes input and output of Bash. Unfortunately, the output contains unwanted characters (\xc2 and \x0d). How can I avoid them with Expect/Tcl?
$ expect -f <(...
0
votes
0
answers
60
views
Use Python interact with an interactive Bash session using the pty module
In (Debian) Linux I'd like to start an interactive Bash session and then pass it commands.
With my attempt it seems Bash isn't behaving as it would in a real terminal and abruptly stops during ...
0
votes
0
answers
36
views
Expect: ssh + sudo - How to get the exit code of the command?
I need to ssh + sudo and came up with this solution to know if the executed command failed.
But I did not manage to return the real retCode of the executed command, any idea ?
# -----------------------...
2
votes
1
answer
56
views
How to get non-latin output from expect script
I'm trying to write a script to test telnet connection. I use CP866 encoding in qnx 6-like OS and need to have the whole cyrillic expect's output.
My expect version is 5.33, tcl is 8.3.5
There is no ...
2
votes
4
answers
84
views
Multithread an Expect script in bash
I have a bash script running on RH linux that takes in a list of devices, loops through the list and calls an Expect script to SSH to each device.
#!/bin/bash
while read device
do
/home/bin/get-...
0
votes
1
answer
58
views
Expect script: "send" command loses first character?
I have a script which connects me to VPN using GlobalProtect:
#!/usr/bin/expect -f
spawn globalprotect connect -p my.server.com
expect "username:"
send "JoeDoe\r"
expect "...
1
vote
0
answers
48
views
Tcl expect not cleaning up on exit, or messing up FIFOs?
TL;DR: expect appears to be messing up named pipes in some obscure way, or not cleaning up on exit.
I'm trying to automate generation of ssh keys, without touching the disk with either the private key ...
0
votes
0
answers
40
views
Using Expect to make SSH connection in first script, and send commands in another
I have an Expect script which when called successfully connects to a device by ssh. If I want I can even send a command right after connecting. However, my goal is to send mulitple commands from a ...
1
vote
1
answer
51
views
Keep process invisible for user in linux dialog script
I got a project with a dialog script, where the TUI will run and the admin can handle passwords.
My problem is that when admin presses changepass for example, i want it to run the command for changing ...
0
votes
1
answer
57
views
ansible expect module does not create the file with creates option
I have the below task
- name: "PATCH| 1.5.2 | Ensure bootloader password is set"
ansible.builtin.expect:
command: grub2-setpassword
responses:
Enter password: "{{ ...
1
vote
1
answer
83
views
Bash using Expect script gives error for ssh call
In a bash script I have an expect segment where it sends commands to a machine via ssh. I have the bash -c there as I need to set environment variables in this command.
But I'm getting an error:
extra ...
0
votes
2
answers
43
views
I need a way to automate an existing script which contains DIALOG [closed]
I have an existing BASH script which needs user input.
To automate other things, I already have a bash script that contains lots of other code.
So the solution should be implementable in bash.
I have ...
0
votes
0
answers
51
views
How to manipulate with time at Expect/TCL scripts
I'm working on integration tests, now there is a need to introduce the ability to manage time. I want to use libfaketime, but something is going wrong.
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/...
0
votes
0
answers
30
views
set timeout -1 is endless and not executing in expect
I am writing an expect script that helps me run a program. When i set the timeout to 10 or 30, the program runs although since it's a big run installation, it doesn't get completed within 30 seconds. ...
0
votes
0
answers
37
views
Is it possible to preserve matched process output in expect interact?
Consider the following expect script:
#!/usr/bin/expect
spawn bash
interact {
-o
hello_world { send "Goodbye" }
}
Under this script, any time the process sends hello_world, the ...
1
vote
3
answers
109
views
Does Tcl or Expect have the ability to quote arguments in a way that is parsable by a shell?
Consider the following short Expect program:
#!/usr/bin/expect
puts $::argc
puts $::argv
If I invoke it as follows, it correctly identifies that there are four elements, but the natural tcl ...
0
votes
0
answers
34
views
Passing variable from shell script to another script using expect
I'm trying to write a script to be able to pass a variable using script_a.sh which extract a value from the database to pass another script script_b.sh which uses this value as part of the input for ...
0
votes
2
answers
421
views
running expect spawn in docker alpine - no such file or directory
I'm new to bash testing and wanted to create a docker image to test a cli. I discovered 'expect' and wanted to try it against this example bash script. Only problem is its failing to spawn a file.
...
0
votes
0
answers
24
views
Unable to use pexpect.sendline for more than 8000 seconds
There is timeout keyword variable for sendline function in pexpect, I wanted to run my script to wait for response even for almost 2 days, for which I am trying to give timeout=43200 but my child ...
0
votes
1
answer
141
views
Unable to get expect scripts to work in Rundeck
I have a fresh install of Rundeck on one of our management VMs.
I used Rundeck at my previous employment so I have some history using the tool.
Background:
We have multiple GitHub repositories ...
0
votes
1
answer
52
views
How to control echo of a spawned process in expect(1)?
How to properly set and get echo status of the terminal associated with a spawned process in expect(1)?
stty -echo executed immediately prior to spawn does not seem to affect the spawned terminal. ...
0
votes
0
answers
27
views
I'm trying to use expect to login to a remote server automatically
#!/user/bin/expect -f
spawn ssh [email protected]
expect
"Welcome to Interface Concept User SSH service [email protected]'s password:" send "myPassword\r"
I expect eof.
This is ...
0
votes
1
answer
153
views
Writing an expect script to execute commands on remote server that Linux itself might not be familiar with such as 'configure terminal'
So far I have spawned a bash script in my expect script that logins to the remote server automatically, which works. Now within my expect script I am trying to run commands such as 'configure terminal'...
0
votes
0
answers
94
views
sh spawn expect - handling multiple lines in expect command
I am encrypting source files using PGP encryption. After importing the key, every time I run the script it is expecting a confirmation. But in Production I am planning to use spawn and expect commands,...
0
votes
1
answer
32
views
use expect command to configure zyxel accesspoint
I can configure my Accesspoint via console and now I want to do this bulk via expect command. It does not work and i suspcect that the problem is that expect does not like : in variables.
This is my ...
0
votes
0
answers
65
views
Expect script fails when outputting command as getting stuck on "--MORE--"
I have a simple expect script running on Ubuntu which I want to automate via cron. The script works fine if I manually run it with my terminal window full screen however if it is smaller than that of ...
0
votes
1
answer
90
views
Expect script frozen when appending output to nohup.out
This is the first time I have done an expect script.
In principle it is a simple script
#!/usr/bin/expect
set timeout 200
spawn XXX/bin/PROGRAM
expect "Choose an option ..."
send "1\...
0
votes
0
answers
43
views
How to read all the arguments into a single variable in expect script, like $@ in a shell script?
I want to read multiple arguments which contain double-quotes into a single variable in an expect script. Through the set command I assign a single argument, but something like $@ we use in a shell ...
0
votes
1
answer
56
views
read variable inside text file used as list in TCL
I've this part of TCL/expect code:
commands.txt sample content:
configure terminal
interface Vlan10
ip address 192.168.1.1 255.255.255.0
set commands "commands.txt"
#
set f [open ...
0
votes
1
answer
166
views
Control-M scp issue with file path name containing spaces
The following is my shell script to transfer TWO files using scp protocol.
The second scp statement shows the source file directory containing spaces (see line 10 where I added a backslash in Badge\ ...
0
votes
0
answers
45
views
Expect: Any way to match a specific rule only once?
I am working on an expect program to ssh into a server and run a few commands.
I have a rule which goes
-re ".*└─.*" {
send "echo Done backing up!\n"
send "...
0
votes
0
answers
19
views
How can I compress repetitive expect matches with a loop?
Suppose I have an array of patterns:
set pat(0) "foo"
set pat(1) "bar"
...
set loc(foo) "123"
set loc(bar) "456"
...
expect {
-re "it's a $pat(0) in ...
0
votes
2
answers
200
views
Rsync within expect script: error "No such file or directory"
I want to execute rsync to update several directories on another machine, without typing the password for each one of them. I decided to try the expect extension by following some simple StackOverflow ...
0
votes
0
answers
101
views
python playwright expect pytest class
How to check expectation if a class contains a word and want to check if a tenant has that word in the class
example of a class:
"x-grid-row x-grid-data-row x-grid-row-selected x-grid-row-focused&...
0
votes
2
answers
105
views
How can I pass commands to SSH when using expect while it doesn't support using double quotes?
I'm automating my login process to my servers using an inline bash script, I'm using expect to automate this, but upon logging into server I also want to print a message, I didn't had any luck with ...
0
votes
0
answers
43
views
Wildcard(*) SFTP in an expect script?
Here's my code:
#!/usr/local/bin/expect -f
set timeout 800
spawn sftp $env(SSH_USER)@$env(SSH_HOST) port(22) ...
0
votes
1
answer
104
views
Expect script to iterate through list of files, fetch file and perform local file manipulation
I have been struggling with this problem now for a few days.
The task would be to connect to an sftp server, iterate through a list of files to
1. Fetch the file from sftp
2. Perform some file ...
0
votes
1
answer
43
views
Can two subprocesses both send messages to stdout inside a Tcl/Expect script?
I have written an Expect script which spawns one subprocess (certbot), parses the output, then executes a second subprocess (a Python script) using data extracted from the first, and finally sends a ...
0
votes
0
answers
20
views
Expect script <<sudo - instructions >> doesn't work
I need to set by Expect a date (ex. 02/28/2024) on a
Blade server (here below showed as litp-admin@ipaddress_2)
In pratice something as here below
ssh - t root@ip_address1 ssh litp-admin@...
0
votes
0
answers
62
views
Expect script: How to interrupt (ctrl+c) running script after defined time
I am very new to expect, so I apologize if I don't already know some basic stuff.
I want to run a script (a demo) for 10 seconds and then I need it to be interrupted by Ctrl+C. I cannot let it sleep ...
-3
votes
1
answer
582
views
Expect script: How to set return value of a command to a variable and exit from script if the return value is not 0?
I am running a command in expect script and I want to exit the expect script if command return value is not 0. I set the variable ret to "$?" like this, which is not working:
send "./$...
0
votes
2
answers
82
views
Is it possible to force `expect` to `puts` a string of nulls without a newline?
Consider the following script, which I'll call PrintNull.tcl.
puts -nonewline "\0\0\0\0"
If I run this script with tclsh, it outputs the four null characters as expected:
tclsh PrintNull....
0
votes
1
answer
838
views
Playright loop while condition is met in addition to that keep clicking on refresh button every 10 seconds until locator found
I am waiting for a text within a locator that only displays itself after a few minutes but the page won't reload on its own to show it - we have a standard refresh button that needs to be clicked ...
1
vote
1
answer
48
views
What is the difference between referencing a HEREDOC and a File when using expect
I have a script that connects to servers via ssh using expect and issues some commands.
When I run the expect script as HEREDOC it quits with an eof by the spawned shell after entering the Password, ...
1
vote
1
answer
141
views
Is it possible to detach a tmux session by sending control sequences using expect?
Consider the following expect script:
spawn bash
expect " \$"
send "tmux\r"
expect " \$"
send "echo hello\r"
send "\x02"
send "d"
interact
...