General :: Expect: Line Seems To Match Exactly However Expect Thinks Not?
Jun 16, 2010
I am writing an expect script. At a certain point there is a rule that produces this debugging output:
Code:
expect: does " Address or name of remote host [x.x.x.x]? " (spawn_id exp8) match glob pattern " Address or name of remote host [x.x.x.x]? "? no This just times out When I use -exact for the expect keyword it does work What am I doing wrong? THe first should also match in my opinion because it is equal as well. Even if I remove the I still have the same issue if I try without -exact. I don't understand. I tried removing the but still got the same.
View 5 Replies
ADVERTISEMENT
Jul 27, 2010
I am trying to make a script that can be used to check server load on a remote server and produces sound on our local machine, when server load exceeds a particular limit.1. I want to execute command uptime or uptime | awk '{print$10}'on the remote server and store the result in a variable(say x), and later use it in the bash script.
Bash Part
#!/bin/bash
x=$(/root/Desktop/exp)
[code]...
View 1 Replies
View Related
Nov 2, 2010
I'm trying to Use Expect to automate a curl function. basically I don't want to type enter for my script to run. Can anyone point me to a good Expect tutorial?
View 1 Replies
View Related
Dec 23, 2010
We have a vendor supplied device that requires user interation, so we are using expect to automate the process. unfortunately the vendor may change the prompts as we take patches, which breaks our expect script. What I need to do is find a way to evaluate whether or not the prompt expect receives matches and if it doesn't I want the script to exit and throw an error. Currently it times out and then moves on to the next prompt.
How do I make my expect script exit if the prompt doesn't match?
View 1 Replies
View Related
Nov 19, 2008
I'am new to expect how do i send function key F12 in an expect script?
View 1 Replies
View Related
Oct 17, 2010
I am having some difficulties with an expect script. What I want is that as soon as expect sees a newline followed by a dollarsign ($), that interact is done. So I would expect something like this to work:
Code:
"
$" { interact }
However it doesn't.
This is debugging output:
Code:
expect: continuing expect
expect: does " " (spawn_id exp6) match glob pattern "#"? no
[Code]...
View 3 Replies
View Related
Jun 28, 2011
I am using expect command to pass password to my script.
like code...
it will send password properly, but after that it will not come out of expect to bash.
View 4 Replies
View Related
May 14, 2010
I am trying to embed expect in my bash script to perform some tasks
USER="username"
PASS="password"
NAMES=`cat full_list`
for i in $NAMES
do
echo $i
[Code]....
The script initially reads a files containing a list of rpm's on each line and then spawns the rpm2ipc command which uploads the particular rpm to a repository. During this process it tries to enter the credentials, where it is failing.
View 3 Replies
View Related
Jun 5, 2011
I am literally bashing (pun intended) my head against the keyboard at this minute! I am trying to automate a script via cron for my centos server. The script requires two user inputs (e.g. read VAR). However, I do not want to edit the original file, as I would like to be able to run it normally as well. It is also made by someone else, and so if an update becomes available, it will be easier to install. My idea is that i create a cron script, to run this second script from, and the only way i could find was with expect. However I am having troubles, In order to test out expect, I have created the following:
test.sh
[Code]...
It looks as if the second input is completely ignored ?! what i am doing wrong? or if there is a more elegant solution to running a script from a script with user inputs?
View 2 Replies
View Related
Mar 21, 2010
i was able to input it directly from the script using this code
Code:
#!/usr/bin/expect -f
set USER "bibingeorge"
[code]...
View 5 Replies
View Related
Feb 2, 2011
i am working on some kind of PBX and i have list of telephone numbers inside a file, i have to insert these numbers into the correct command and then telnet to a remote server and execute these commands. i can read the telephone numbers and insert them into the command with no problem, but when i try to insert these commands into the send i face problem. here is the basic code
#!/bin/bash
read msisdn < input
string="ZZZZ:MSISDN=$msisdn;"
[code]....
i can make external loop inside the Bash which read the input file and issue the command and then telnet and execute, but this will make the script connects and disconnects again for each line which cause high load on that server and hardwar problem. i am wondering if there is an option inside the expect interperter which makes the send read directly from a file... somthing like this:
expect "<"
send "input-filename
"
expect "<"
expect eof
View 1 Replies
View Related
Aug 9, 2010
I'm trying to use expect to telnet to web server and send HTTP command like POST, GET, etc.
Here's my code...
But this gives an error
couldn't read file "/cgi-bin/authgw-cgi": no such file or directory
I think this is because of /
How to send / in expect?
View 3 Replies
View Related
Mar 7, 2011
I'm using expect to log into a remote server and run a script. I want to able to have expect edit the output from that script, on the remote server, in VI. Has anyone ever done this before, it seems as though the expect interpreter has nothing to expect once VI is started, the file pointer starts at the beginning of the line, and expect usually reads the characters before the pointer.
spawn ssh user1@$remote_server
expect "password: "
send "$password
[code]....
View 2 Replies
View Related
Mar 25, 2010
I'm using a small "expect" script to automate password entry for some file copying.The automation works fine, but the "Password: " prompt still displays on the screen. How do I hide the prompts so the user doesn't see "Password: " on the console?Here's the relevant section of my script:
Code:
expect -c "spawn /usr/bin/scp -q $2 user@$1:$2
set timeout 60
[code]....
View 9 Replies
View Related
Jul 9, 2009
I am trying to return a variable's value from an expect script to the command line or a calling script..$res has a value of 1.
I do a ..
expect "*"
sleep 1
[code]...
View 11 Replies
View Related
May 21, 2011
I'm trying to use expect to get data from telnet
Here's my code :
Code:
set equipment [lindex $argv 0]
set trunk [lindex $argv 1]
set fraction [lindex $argv 2]
[Code]....
so in bold letter not send in 1 line, but i want sent it to 1 line
View 2 Replies
View Related
Apr 13, 2011
I wrote an expect script that tests user authentication against a RADIUS server. The username is an email address, including an @ sign. I recently wrote an HTML/PHP front end to allow others to input username/password into a form and then see the results when they hit submit. Expect code that takes two args username, and password
Code:
expect "#"
send "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code
"expect "#"
[code]....
Every works as it's supposed to, except for the output of the script. When it displays on the webpage, it's segmented weirdly with all throughout. What I've found is when I remove the @ sign in the username input, it fixes it. Is there any part of HTML or PHP that treats the @ as a special character? 1 more thing is that I have another HTML/PHP/EXP script that works fine with the @.
View 2 Replies
View Related
Jul 12, 2010
I am starting a new job, and need to brush up on my expect scripting. does anyone know of any online resources, e.g. telnet sites that I can play about with?
View 4 Replies
View Related
Nov 12, 2010
I've got an Expect script that establishes a ssh connection to the iLO interface of a server. Problem is it drops me back to the local terminal and I can't enter commands to be executed on the remote host. How do I get it so it logs me into the server then leaves me connected to it?
Code:
expect -f - <<-expect_script_end
spawn ssh -o StrictHostKeyChecking=no $user@$host
match_max 100000
expect "*?assword:*"
send -- "$pass
"
send -- "
"
expect eof
expect_script_end
The ssh server running on the iLO interface appears to be sending eof's which is causing expect to exit. How can I get it to ignore them?
View 3 Replies
View Related
Aug 2, 2010
Is there a similar thing in expect, as there is 'read'(Read a line from standard input) in bash?I mean one could easily construct following script in bash:
Code: > cat script.sh
#!/bin/bash
read -p "Username: " uname
[code]....
View 1 Replies
View Related
Jul 6, 2011
I have a script which uses a function and also uses expect.
If I have #!/bin/bash as the first line, the function is recognised. The expect calls are not, failing first with spawn.
If I have #!/bin/expect as the first line, the expect and spawn work fine. The function is not recognised.
My friend Google brings up examples with both these lines one after another in script files, just like Im doing. Except for me it doesnt appear to work.
Where am I making my beginners mistake in not understanding how this works ?
View 2 Replies
View Related
Dec 21, 2010
I'm trying to get Expect to execute commands on a remote server using SSH with username/password authenticationMy current expect script is
Code:
#!/usr/bin/expect -f
spawn ssh -tq root@my_hostname "whoami"
[code]...
View 2 Replies
View Related
Mar 25, 2010
just as an excercise I'm trying to write a script that would automaticly install java using an expect script.I create the expect script with autoexpect and it works. But only if I don't change the size of the window. It always hang at the line with "--More--". So I changed the script and it boiled down to this
Code:
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
[code]....
View 3 Replies
View Related
Jul 29, 2010
I have a Thomson TG784 router, where I would like to log in automatically and execute dhcp server lease flush command.
When I log in using telnet, the process is following:
Code:
View 6 Replies
View Related
Feb 8, 2011
I'll post the entire code here, and then specifically highlight what is just failing in a fashion I'm apparently incapable of fixing a few hours later:
Code:
#!/usr/bin/expect
# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line
[code]....
I've had all kinds of different results and problems, but I've never been able to successfully log into multiple servers, though the first server in the list most times works okay (though might not on this iteration). I'm a bit hack and slash and I would be very greatful not only for a solution, but any tips on how I should have done this and places where I could clean up my code.
View 1 Replies
View Related
Nov 19, 2010
I want to write a function in expect/tcl which logins into a router. but the syntax is a little confusing .
case 1: router prompts for "username".. {we put in username and password .. if they are incorrect we try with another username and password. if we succeed into getting a prompt we return 1 .. if both username passwords are wrong or we time out we return 0 }
case 2: router prompts for "login" .. {we put in username and password .. if they are incorrect we try with another username and password. if we succeed into getting a prompt we return 1 .. if both username passwords are wrong or we time out we return 0 }
case 3: router prompts for "password" only .. { we login just using the password and get to the enable prompt}
View 3 Replies
View Related
Oct 4, 2010
I have the following code which I've thieved from here, there and everywhere:
Code:
[root@localhost /]# cat autossh
#!/usr/bin/expect -f
[code]....
View 3 Replies
View Related
Feb 8, 2011
I am writing an expect script and I wish to use environment variables that are defined outside of the script.
View 2 Replies
View Related
Dec 11, 2010
trying to see IF i dont get the right results repeat the command until it will or quit after 3 tries....
expect -exact "->"
send -- "test_read_register 0,0x37
"
if {! [regexp {Address 0x00000000} do send -- "test_read_register 0,0x37
[code]....
It should read
Read: Address 0x00000037, Data: 0x0000000b
but sometimes it comes out to this
Read: Address 0x00000000, Data: 0x00000000
therefore ill have to run the command again IF I Dont get the right results...
View 1 Replies
View Related
Apr 22, 2010
I am moving my migration forward and am trying to get my expect scripts tested and found one that no longer works. Quite simply, it spawns a telnet session to a router.
#!/usr/bin/expect
set env(TERM) vt100
set timeout 3
set send_human {.1 .3 1 .05 2}
set timeout -1
#
spawn telnet 10.254.3.232
and that's it. The result of the script is that the command to spawn simply shows up on the screen like it is a puts command. On my older openSUSE system, it worked fine. I am running Ubuntu v9.10 desktop, and expect and its libs are patched to the latest rev, expect is 5.43.0.
View 1 Replies
View Related