replace space with underscore in expect script
#!/usr/bin/expect -fset cmd "abc def ghi lkj"set log [ expr echo ${cmd// /_} ]I would like to log variable as ghi_lkjfirst I wast trying to replace all spaces with underscores and then remove first two...
View Articleredirect each command output to respective log file expect script
set commands {"show phone xxx 11""show phone yyy 22""show phone zzz 33"}spawn ssh -o StrictHostKeyChecking=no $UserId@$hostsleep 15#wait for password promptexpect "*assword:"#send password send --...
View ArticleHow use 'expect' to run 'openconnect VPN' in background?
I'm a newbie to write bash script,I was using macOS catalina, andI write a bash script which use expect to run openconnect,#!/usr/bin/expect...spawn sudo openconnect --user xxx...
View ArticleIs it possible to carry local RSA keys to remote computer (live) and use...
Is it possible to store an SSH-id in some sort of session (like expect or ssh) that is running on the local machine, swing into a remote box, and execute a shell command in the remote box as if the...
View ArticleExiting an Expect Script
I have this expect script, that will log into a host, run a command, return it's contents and exit. What sort of cleanup/proper exiting needs to happen when I've finished running my command? This...
View ArticleWhen using expect script on boot the output of a list of lines gets shorted....
I use the following script that I generated with autoexpect. When used on command line command sudo surfshark-vpn multi gives a list of about 15 lines and then asks for a final input by the user in the...
View ArticleFailed attempt to expect and send
I'm trying to write a script which git clone.my script:git clone ssh://git@domain.com/myproject.gitexpect "Enter passphrase for key..."send "myPassword"read -p "enter..."and after run it I got:Cloning...
View ArticleUnexpected expect/ssh question
I am seeking to automate ssh password based logins (and a series of actions after logging in).I am aware that the ssh password prompt bypasses STDIN. To that end I put together a quick expect...
View ArticleCatching the query results executed in the remote PostGreSQL server through...
I want to catch the PostGres query results that gets executed in the remote server (passwordless-ssh) via expect command that is used to supply the password for the given PostGres user.Actually, there...
View ArticleExpect script is not working on linux machine
when I have to do ssh to one of my machine below is the command and if I type 'yes' it is working and able to login as below.ssh root@192.168.1.177The authenticity of host '192.168.1.177...
View ArticleHow can I clean up output from expect?
Background: I'm using expect to connect between AMCE.sh and a managed network switch. I can connect to the switch via SSH, log in and issue commands but because of the way the switch manages SSL...
View ArticleExtract contents of jar file to curl using scp
I have a jar file containing a javadoc tree on one box. I need to transfer it to another box and unpack the jar in a specific directory (which may not exist).I have the username/password of the...
View Articlehow to send remote script parameters through expect script
I have a program that creates a dynamic shell script using heredoc "stop_remoteServer_script.sh"template of heredoc belowcat<<_STOP >...
View ArticleHow to break ping command without waiting for its complete output in expect...
I am new to expect programming. In my script i need to run multiple ping commands.I am running below mentioned command: ping $ip rep 100 size 1500If connection is successful than its all good, but if...
View ArticleHow to pass variable arguments to expect
I want to pass a variable number of arguments to a expect script:#!/usr/bin/expectset timeout 10spawn ssh -o "StrictHostKeyChecking no" [lindex $argv 0]@[lindex $argv 2]expect "password: "send "[lindex...
View Articleexpect can't send a passphrase for key
My company offered me a server to do my code job. I have to enter a passphrase every time while login the server.~$ ssh -o StrictHostKeyChecking=no -p 22 me@x.x.x.xEnter passphrase for key...
View ArticleAutomating vncserver with expect not working as expected
I thought of automating the part when i first run vncserver, since it ask for a password (and while i know there a flag to pass a passwd file, i prefer to generate a new one every time i need/want...
View ArticleSend Ctrl+C to script running through ssh
So i got a script that i run through ssh like so:ssh user@ip <<'EOF'export TERM=xterm#list of commands hereEOFProblem is, in certain instance, i need to use Ctrl+C in the terminal, mainly when...
View ArticlePrevent expect from hanging when running through ssh
Based on another post's answer, i managed to make expect automate vncserver through ssh (optionally on a chroot in this case), like so:ssh user@ip "rm ~/.vnc/passwd"echo -n "`PASS_VNC`" | ssh user@ip...
View Articlezsh, zpty: How to read the output of a process after it has exited?
Start some command with zpty:zpty -d x ; zpty x 'echo hi' ; sleep 1 How do I read its output now that it has exited?zpty -r xReturns 2, and this behavior seems expected per the manpage.
View Article