Programming :: 'read' Functionality In Expect Script?

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


ADVERTISEMENT

Programming :: /usr/bin/expect : Script To Check Server Load Using Both Expect And Bash?

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

Programming :: Expect Script: Send Function Key F12 In An Expect Script?

Nov 19, 2008

I'am new to expect how do i send function key F12 in an expect script?

View 1 Replies View Related

Ubuntu :: Good Expect Tutorial For Programing With Expect?

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

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 View Related

Programming :: Send '/' In Expect?

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

Programming :: Control VI With Tcl And Expect?

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

Programming :: Use Expect To Get Data From Telnet?

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

Programming :: HTML To PHP To EXPECT Formatting?

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

Programming :: Resources For 'expect' Practice?

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

Programming :: Expect: Reacting On A $ At The Beginning Of A Line?

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

Programming :: Expect Script To Install Java - Not Getting It?

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

Programming :: Expect Script To Telnet Into A Router

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

Programming :: Expect/TCL - Unable To Get The Correct Results

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

Programming :: Expect/Tcl Function To Login In A Router?

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

Programming :: Expect Command And Multiple Arguements?

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

Programming :: Use Bind Variables In An Expect Script?

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

Programming :: TCL / Expect - IF Results Are Different Then Send A Command?

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

Programming :: Adding Functionality To Perl Script?

Mar 18, 2011

I am a C++ programmer and never used Perl. add a functionality to a script, in Perl language. Originally, the script takes 1 file input and I run it in this way: ./script.pl file1 It is designed to return specific words from that file, example:

user
admin
printer-1
user-2
server

The idea is that I need to be able to provide the script with a second input file that contains only few words, each on a new line. These words might have a "dash". Example:

printer-2
server
user-2

I will be running the script as: ./script.pl file1 file2 In return, the script should check if every word in file1 does exist in file2. If it does exist, then the script displays it. In the example I provided above, the script should only return:

server
user-2

Here is the script I have. What's in black is the original working Perl script and what's in red is what I would like to add in Perl Language:

!/usr/bin/env perl
my ($table);
for (every value in file2)
{

[code]....

View 7 Replies View Related

Programming :: Expect Script Error: Spawn Not Found

Dec 13, 2010

I am working on an expect script to login into a server and copy few wars across the folders. But when i execute it I am getting the following error:

[exec] loginServer.sh: spawn: not found.
[exec] loginServer.sh: expect: 0403-006 Execute permission denied.
[exec] send: -- unknown

The first line is : #!/usr/bin/expect -f.Is this anything to do with server setting or configuration that doesn't allow spawn??

View 3 Replies View Related

Programming :: Expect/TCL Logging - Create A Clean Log File?

Apr 14, 2011

I've written an Expect script that assists with change management on Cisco devices. The script creates log files for pre-change, the change itself, and post-change. Each log and its commands is triggered by a ! command. For example:

Code:

./dochange.exp hostname
<script spawns bash, user SSHes to hostname>
!PRE

[code]....

All of this works fine. My big hair-pulling hiccup is that the resulting log files are filled with raw backspace characters! I am using log_file to log the output from the script. I stop and restart logging with a new file when needed. However, the log files are pretty much unusable. After doing some research, it looks like log_file sends output to the file in real-time, unbuffered. When I hit a key, it's immediately sent to the log. What I would like is for only the resulting string to go to the log. If I start to type 'reload' and instead type 'show run', I don't want 'reload' to be listed in the log at all.

View 1 Replies View Related

Programming :: Pass An Expect Command Result Into A Variable And Then Use It Again?

May 4, 2010

I'm trying to create a program that would locate the oldest file of a certain type on a server. Here's the commands:

OLDEST_PATH=`find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1`
OLDEST_FILE=`find -L $OLDEST_PATH | grep .mp3 | sort -f | head -1`
ls -al $OLDEST_FILE

I'm writing this all in expect but I'm having problems. The main problem I have is whenever I try to run the first command, I can't seem to isolate the result of the OLDEST_PATH so that the 2nd command will work. There always seems to be a newline in the variable and the result is only "find -L" command running and it bypasses the variable. If I can just figure out how to get the 1st and 2nd command to work, then I can figure out the 3rd. Here's some code:

Code:
send "find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1
"
sleep 20
expect -re "(.*)

[Code]....

I know there is a better way to write this. I've tried multiple ways and this just happens to be the last way I've tried it. If you try running this, you'll notice that there is still carriage returns after the result of OLDEST_PATH and it prevents the 2nd "find" command from working properly.

View 2 Replies View Related

Programming :: Send: Spawn Id Exp1025 Not Open In Tcl/expect

Apr 21, 2010

my tcl framework give exception - send: spawn id exp1025 not open - while executing command - exp_send "echo $ABC". Though this is very sporadic in nature and frequency of occurrence is very less, but still i need to fix it.

I have following queries

- why does this occur so sporadically?

- how do i fix it?

- what shall i do to avoid such exceptions in future.

Note : The function which runs the exp_send command always spawn a bash whenever it is called.

View 3 Replies View Related

Programming :: SDL - Suddenly Music Functionality Stopped Working?

May 15, 2011

The problem started with that I got a lot of errors about missing header files included from SDL_mixer.h when I attempted to compile my projects. I looked in the directory of this file, and all header files were missing except SDL_mixer.h Resolved this by compiling and installing the base SDL library package. Programs that got recompiled and were able to play music before suddenly produced no music, but sound effects worked. However, old binaries that were compiled prior to the issue with the missing header files played music fine. What the heck is this? I get no errors, nor warnings; none at compilation, none on execution. The kernel pool (dmesg) is clean. There is also another strange issue, which perhaps has nothing to do with the first issue. x86_1$ ./fire XDM authorization key matches an existing client!Couldn't initialize SDL: Couldn't open X11 display.

View 1 Replies View Related

Programming :: Sub Classed Gtk::VScale Looses Scale Functionality

Mar 20, 2011

I'm using Glade and Anjuta to build an oscilloscope and wanted a dial like a real scope, so I sub classed a VScale and painted my own dial.In the process I lost the ability to move the dial.I' ll have to implement the interface from scratch like I started from a base Gtk::Widget.Is this the way it is, or are there ways to change visual appearance of the VScale and still keep it reacting as a VScale?

View 2 Replies View Related

Programming :: Expect: Prevent Output From Spawned Process To Appear On Stdout?

Jul 3, 2009

I have this expect process:

Code:
spawn -noecho telnet my.host.com
expect {

[code]...

View 3 Replies View Related

Programming :: Tcl Expect - Unable To Use Regular Expression In Interact Mode

Dec 8, 2010

I have something like the following in my expect script:

Code:

interact {
-nobuffer -re {^s
} {

[code]....

I have put the "^" anchor to match only those pattern that does not have anything before "s" e.g.

1.when I type "s" followed by "enter" key it should match.

2.if I type something like "chess" followed by "enter" key it shouldn't match. the second case is also being matched by the regular expression I have in my code.

View 4 Replies View Related

Programming :: Can Expect Return Control Of A Spawned Process To A Shell Script

Nov 19, 2009

Is it possible to have an Expect script spawn an SSH session, log in, then go into interactive mode and give control of the SSH session to a Bash script? Here's a simplified example of the script so far:

Code:
#!/bin/bash
expect -c "

[code]....

View 4 Replies View Related

Programming :: TCL Expect Script That Spawns A Telnet Session To A Nortel - Response In Expect_out Is Not Consistent

Dec 2, 2010

I have a TCL expect script that spawns a telnet session to a Nortel DMS100 to execute some commands. The strange thing is that the response in expect_out is not consistent. It sometimes contains a extra enter or newline. This results in differences in the expect out buffer. Here is a part of the script:

send "time
"
sleep 1
expect -re ">"

[code]...

This command displays the time. The correct output should be (with log_user=1):

>time
Time is 11:44:04
>

But sometimes the output is:

>timeTime is 11:45:04
>

As you can see here the is missing on the command that expect sends , or at least in the echo that is comming back. I use a split command to filter out the response in the expect_out buffer, but this fails when the is missing. Here is a example with the debug enabled:

[code]....

I suspect it has something to do with a slow response of the switch. I tried to send the time command slow and with the send_human but the result is the same. A timeout between the send and expect also doesn't help.

View 1 Replies View Related

Programming :: Bash-shell-like Less Functionality In The Python Shell?

Jun 25, 2010

Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?

Example:

Code:

>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...

I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved