expect

Running multiple instances of one tcl script

北战南征 提交于 2019-12-26 03:33:12
问题 Currently I am reading in host names from a file using a foreach command and using this hostname to connect to the device. All this is done within my TCL script. Is there a way I can run multiple instances of the script so that each device is queried separately? Something like a bash script similar to: for hostname in file; do log.tcl $hostname & done I believe this is similar to multi threading. Another question I have is that, when running multiple instances of a script, and each script

linux - telnet - script with expect

本小妞迷上赌 提交于 2019-12-25 16:25:47
问题 I was writing an expect-script which communicate with a server via telnet, but right now i need to evaluate the reply from server. Usage: ./edit.expect EXPECT script: #!/usr/bin/expect<br> spawn telnet ip port expect "HUH?" send "login testuser pass\r" expect "good" send "select 1\r" expect "good" send "me\r" expect "nick=testuser id=ID group=testgroup login=testuser" send "edit id=ID group=3\r" expect "good" send "quit\r" If i send the command "me" i get a reply from the server which i need

Expect script not sending commands after successful ssh login

好久不见. 提交于 2019-12-25 09:16:14
问题 When launching the following script, the ssh login succeeds, and I'm able to interact, but it doesn't send the cd folder command. Is my expect "$" command useful at all if I know for sure that this is the first command I want to send, and how can the cd folder command be sent? Here's the short expect script: #!/usr/bin/expect eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no host@exemple.com expect "password" send "mypassword\r" expect "$" send "cd folder\r" interact Thank you! 回答1:

Convert expect output from DOS to UNIX style in realtime

本秂侑毒 提交于 2019-12-25 05:32:18
问题 I write some expect scripts by connecting to a remote host through serial connection. My problem is that the output of the spawned process (enabled with log_user 1 ) contains DOS-style endings (each line being terminated with ^M when reading logs in VIM). I normally run dos2unix on all logs at the end of the expect session, to get rid of them. Can the conversion be done in real time? 回答1: It turned out the problem is really simple. What I am doing with my scripts is calling them like below:

How can I pass a filehandle to Perl Expect's log_file function?

我的未来我决定 提交于 2019-12-25 04:42:53
问题 I feel stupid for asking this, but I've tried a couple things and I'm not sure where to go with it. From the Expect.pm documentation: $object->log_file("filename" | $filehandle | \&coderef | undef) Log session to a file. All characters send to or received from the spawned process are written to the file. I'd like to pass the $filehandle to log_file. However, when I tried this: open (LOG, ">>" .$opt{l}); my $sess = Expect->spawn("telnet $ip"); $sess->log_file(LOG) I get a file named 'LOG' in

Conditional statament inside expect command called from a bash script

邮差的信 提交于 2019-12-25 04:35:29
问题 I've been trying to automate some configuration backups on my cisco devices, i've already managed to do the script that accomplishes the task but I'm trying to improve it to handle errors too. I think that's necessary to catch the errors on two steps, first just after the 'send \"$pass\r\"' to get login errors (access denied messages) and at the 'expect \": end\"' line, to be sure that the commands issued were able to pull the configuration from the device. I've seen some ways to do it if you

Linux Expect/TCL Comm Port Comunication Cisco Switch

天涯浪子 提交于 2019-12-25 03:26:46
问题 I have done much reading on TCL/Expect and wrote the following script to connect to the comm port on my RPi-Kali-Linux box. #!/usr/bin/expect -f set timeout -1 ;#set the portID and open it for reading and writing set portID [open /dev/ttyUSB0 r+] set baud 9600 ;#Configure the port with the baud rate ;#and dont block on read, dont buffer output fconfigure $portID -mode "9600,n,8,1" fconfigure $portID -blocking 0 -buffering none ;#Write to the comm port by sending a carrage return spawn -open

How to pass local shell script variable to expect?

天大地大妈咪最大 提交于 2019-12-25 01:48:16
问题 My question is related to How to pass variables from a shell script to an expect script? but its slightly different: Apart from passing two runtime shell script variables, I want to pass a variable thats inside the shell script For eg: #!/bin/sh d=`date '+%Y%m%d_%H%M'` expect -c ' expect "sftp>" #use $d here(how?) ' 回答1: You don't need to pass a date variable into expect. It has a very good date command builtin: expect -c ' # ... set d [timestamp -format "%Y%m%d_%H%M"] something_with $d # ...

can you run half a script in bash and the other half in expect

耗尽温柔 提交于 2019-12-25 01:34:46
问题 Im trying to make a script to automate ssh login and download of a file for multiple ip addresses that are kept in a file, im using a for i in $(cat /dir/file) , problem is the cat function is working in expect so i cant use it on a script that is interpreted with expect. I wanted to know if it is possible to make half of the script be interpreted by bash and the other half by expect like this #!/bin/bash code........ #!/usr/bin/expect code........ my code now looks like this #!/bin/bash

Formatting Expect Script Inside of User Command in Bash Script

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 17:42:24
问题 So I have three installers for NVIDIA's CUDA API -- the first is a driver and comes with nice silent install flag options (but you have to be root and have to have run level 3). The second two follow are shown manually installing below (cut out the long mess of install afterwards for brevity) [root]# sh cudatoolkit_4.1.28_linux_64_rhel5.x.run Verifying archive integrity... All good. Uncompressing NVIDIA CUDA......................................................................................