EXPECT help with full buffer(?), or other available solutions
First, to level set: I'm proficient enough with basic BASH scripting for simple things (say, 4 out of 10), but this current project really requires a higher understanding of EXPECT than I have.
I have an interactive-only control application residing locally on a database server that I would like to interact with programmatically with an EXPECT script (again, local), and "display" all settings into a file.
This script does exactly that:
So the problem: the output from the "display" command is apparently(?) longer than expect_out(buffer), as I only get about 2/3 of what is printed to the screen (approximately 7k). In reading other posts, I'm unclear if this is actually a buffer limitation, or some timing problem - but the application, script, and settings all reside on same server (no network latency), and the application isn't secure, so no logins required (besides being on the server). Running it manually is instant, so I don't believe it's a timing issue - just to be safe, I sprinkled in some Sleep time, in case the expect buffer is slow.
I've seen some posts that recommend appending the buffer to a variable, but I've not had luck getting that to work (again, my EXPECT skills aren't that sharp).
Also ~ while I need to use EXPECT to send commands to this interactive-only program, I'm open to any solution that puts the output of the screen into a file - I can parse it into what I need from there.
For instance, I could turn on SCRIPT <filename> terminal recorder and then run:
...and then EXIT the script command.
Unfortunately, I couldn't figure out how to get SCRIPT scripted (heh heh) - I could put the SCRIPT command at the beginning of the script.sh, but it would hang after starting, and never get to the EXPECT (it was expecting some interaction?). Typing this, I've never tried SPAWNing SCRIPT <filename>, then SENDing an EXIT at the end (i.e. nested EXPECTs)... Not sure if (a) you can nest EXPECT the way I'm thinking, or (b) I can even start SCRIPT that way.
Anyway - I'm not stuck on any one particular solution... anything that can capture what scrolls along the screen into a file, in a scripted fashion (I'm doing this one last step manually) will be extremely helpful.
I'm sorry I don't have an example you can run (unless you have a Teradata hot-standby node) - you'll have to trust me that the above two scripts work just fine - except something is running out of buffer/time/something, and failing to record the entire output.
Hey Chubler_XL ~ your post worked perfectly, thanks!!
I think I follow what you did - like other posts I've read, it's appending the buffer to a variable prior to file write... unlike other posts I've read, you're doing this per \r - also, unlike other solutions I've seen, this one worked the first time
Hi,
I am capturing command's output on remote host using Expect. The problem is that the command line arguments also getting print with the output in file and also need to print last two relevant columns (percentage used and its mounted point).
The output of $exp->before() buffer is :df... (1 Reply)
I have written an application in Tcl-Expect which spawns minicom and
sends and receives data via the serial port. Sometimes i see that the
application receives control characters along with human readable data.
A search on the internet tells me that the control characters are
nothing but the VT... (0 Replies)
My cron file. Copied $PATH
# Minute Hour Day of Month Month Day of Week Command
SHELL=/bin/ksh
PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/perl/lib:/perl/lib/lib/perl5:/perl/scripts:.:/perl/lib/local:/home/popeye:/temp
0... (3 Replies)
Hello everyone!
This is the situation:
I execute this command from a bash script:
telnet 10.99.246.14 6001 >> output.txt
The question is:
How I do to execute this command and empty the buffer when is full?
The script is always running.
Thanks a lot! (2 Replies)
This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Hi All,
I have to write one expect script to login to one system.
I am using
set timeout -1
match_max 100000
spawn ssh root@hostname
Now when I do spawn ssh to that host it send some warning message and one challenge
Challenge: 111-2345
I need to read this challenge value and has... (1 Reply)
Hello to all...this is my first post (so please go easy). :)
I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Hi Group,
I am struggling to increase buffer size of expect,
sometimes after increasing the buffer size, expect captures all my expected output, sometimes not, :-(
I tried
match_max 700000
set expect_out(buffer) {}
Could anybody guide me for any solution.
HTH,... (1 Reply)