General :: Not Able To Come Out Of Expect / Sort It?
Jun 28, 2011I 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.
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.
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.
I have a WRT610N router which has an inbuilt media server. The cool thing is, you get 2 wireless networks, so you can label one as abg & one as N. I've been ftp'ing files from the media server, which is a really good way of testing wireless performance. I was just wondering what sort of performance you should see from 54Mbps & N ?
Under FC11 I see anything between 1500KB/sec download & 2400KB/sec download when it's on the N band (5GHZ) but reports 54Mbps connection. My mac on the other hand pulls around 3000KB/sec transfer on the N band.
I was just wondering what sort of "standard" performance I should expect ? I'm fairly sure that linux latest kernel, the 5GHZ router & Intel Corporation PRO/Wireless 4965 are not connecting N band. Searches on the news groups shows people asking what G band, N band is, but no ball park, expect these figuers.
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]...
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 RelatedI'am new to expect how do i send function key F12 in an expect script?
View 1 Replies View RelatedI 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.
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?
i was able to input it directly from the script using this code
Code:
#!/usr/bin/expect -f
set USER "bibingeorge"
[code]...
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
What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?
View 2 Replies View RelatedI Want to run below script withing expect utility
Code:
mystring "abc:-)"
mystring1=${mystring/)/.}
We switched from unix to linux and we have an old report that extracted data from a database, output to an ascii file and then sorted the results in the file based on different arguments. The report now blows up when it runs,and I can only guess it is because the options for sort on linux differ slightly from unix.For example, here is one of the commands issued from within the report app that ran on the old unix box:
if sort-sequence = "descending" then
'sort -t~" -f +3.0f -4.0 +5.0r -6.0 -f '
else
'sort -t~" +3.0f -4.0 +1.0f -2.0 -f'
I will eventually rewrite the report to store the data in a local table, but I can simply adjust the options to suit the requirments of linux. Basically, I need to know if this can be a quick fix for the short term.
I want to run an expect script generated using autoexpect within another script,the expect script has to go into super user mode execute some commands and then exit and come back to user mode.When the script is run in the command line it works fine,i want the script to run within another script
View 7 Replies View RelatedI'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?
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]....
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]....
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]...
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
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 @.
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 RelatedI'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?
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]....
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 ?
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?
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]...
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]...
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]....
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:
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.