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


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


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

Programming :: What's Best Practice For C-Style Stings?

Apr 22, 2011

I have searched the net for The Best Practice of C-Style Stings, but the examples i have found aren't sufficient.Can someone please show me The Best Practice for C-Style Stings, or direct me to something i can read that shows in details the best practice.

View 12 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:


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


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 :

set equipment [lindex $argv 0]
set trunk [lindex $argv 1]
set fraction [lindex $argv 2]


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


expect "#"
send "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code
"expect "#"


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 Locking In C?

May 9, 2011

I am going to write two or more programs that will take control of the same resources on Linux. What are the common methods/functions that can do locks/synchronizations in C?

View 1 Replies View Related

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
read -p "Username: " uname


View 1 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:

$" { interact }
However it doesn't.
This is debugging output:
expect: continuing expect
expect: does " " (spawn_id exp6) match glob pattern "#"? no


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

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally


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:


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:


# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line


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:

[root@localhost /]# cat autossh
#!/usr/bin/expect -f


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


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 :: 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] spawn: not found.
[exec] 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:


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


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`

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:

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


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 :: Expect: Prevent Output From Spawned Process To Appear On Stdout?

Jul 3, 2009

I have this expect process:

spawn -noecho telnet
expect {


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:


interact {
-nobuffer -re {^s
} {


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 :: Avoiding Deadlock With Multiple Locks / Resources

Jun 16, 2011

Thanks to a recommendation and extensive help at, I have a multithreaded PHP script running in the cloud which fetches images and stores them the cloud. It's fast and seems quite stable.However, I believe I'm faced with a situation where I need to introduce an additional lock to my code so I'm faced with the task of managing multiple locks while avoiding deadlock.I was wondering if anyone had experience managing multiple locks in a MT environment and could recommend specific functions and data structures. I've been reading up on resource management in MT code and understand a few things:

1) Any shared resource (global and static vars, memory, file descriptors, etc.) generally needs to be protected by some kind of mutex, lock, or other sync var.
2) There are certain necessary conditions for deadlock to occur.
3) You generally need a sequence or hierarchy of your resources so that all threads request them in the same order. This sequence must be the same and immutable for all participating threads, whether local or remote.
4) Recursion is a very common cause of deadlock, so a process should know what locks it has acquired previously in order to avoid blocking in the attempt to re-acquire those same locks again.
5) There are a variety of algorithms described such as the Banker's Algorithm, the Chandy/Misra solution, etc. to help avoid deadlock.

I'm hoping to come up with a technique for properly handling multiple locks/mutexes/sync vars that I can re-use in the future, but I'm still coming to grips with the algorithm descriptions and am unsure precisely what sorts of data structures or functions I'll need.

View 3 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:

expect -c "


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 ">"


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

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:


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

Fedora :: Practice Securing & Scanning System

Nov 29, 2010

Recently I've been going over a few resources (like Guide to the Secure Configuration of Red Hat Enterprise Linux 5) some forum members have provided and I've been using other resources I use for work (like the UNIX STIG requirements). I would like to improve my skill-set on hardening a linux server (for work and personal interest). Is there a specific linux distro I can install that is purposely corrupted/vulnerable where the sole goal is to secure it, and then have the means to scan it to make sure all vulnerabilities are patched and secured?

View 6 Replies View Related

Copyrights 2005-15, All rights reserved