Ubuntu :: Bash Script With Expect - Headers ?

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


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

Slackware :: Bash - Random Headers When Starting Bash In X?

Jan 13, 2011

I have searched and searched and maybe I don't know how to articulate this issue with out just posting the problem I'm having. Every time I bring up a terminal window I get the following "Header"

declare -x COLORTERM="gnome-terminal"
declare -x CPLUS_INCLUDE_PATH="/usr/lib64/qt/include"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-xSFd6zqrYQ,guid=dc5e07974559da016842742900000090"
declare -x DISPLAY=":0.0"

[Code]...

To be honest I cheated and used the .bashrc / .profile files from Ubuntu and all was working fine for a while now and it seems something changed to cause this... any ideas on why I am getting this? I checked my .bashrc and my /etc/profile and it doesn't look like anything is amiss..

View 3 Replies View Related

General :: Embed Expect In Bash Script

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

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

CentOS 5 :: Can't Install Kernel-headers Glibc And Glibc-headers?

May 11, 2010

Yesterday, I think I did something stupid: I removed kernel-headers, gcc, glibc-devel and glibc-headers. My box is a CentOS 5.4 webserver (it has loads of packages installed, but that was done through Virtualmin config, so it's quite coherent all in all). The thing is that now I need to reinstall at least the headers and glibc, but hey! this is what I get :

[Code]...

View 19 Replies View Related

Software :: Which Headers Are "The Headers"?

Jun 14, 2010

been a programmer for a while; on windows mostly but I'm starting to learn all that I can about linux software.I've picked up a funky little NAS which has ssh access to its (i believe uLinux) environment. I've also managed to find a compiler for it (gcc compiled for ARM - GNU/Linux).The plot thickens.I've had some headaches but I've now managed to compile Apache2 without DSO support... so far so good.In getting this far I've been told by a number of people i will need "the headers" specific to the device (the NAS didn't come with source code).

Since Apache 2 (without DSO) compiled fine I know i definitely have some headers. But DSO won't build with errors that lead me to believe it may be a header issue.The question:So i have some headers which educated guess work suggests to me that these are the headers for the std c/c++ libraries.finding "the headers" to know what they are the headers for

View 4 Replies View Related

Ubuntu :: Using 'expect' And Scp - Hiding Prompts?

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

Ubuntu :: Expect Script To Establish SSH Connection

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

General :: Not Able To Come Out Of Expect / Sort It?

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

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

Ubuntu :: Can't Spawn Telnet Session In Expect Script

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

Ubuntu Installation :: Where To Find Expect That Will Work On10.10

Mar 25, 2011

I'm new to Ubuntu and am looking for the Tcl/Tk extension Expect. I have several Expect scripts that I would like to use but I don't know where I can find a version of Expect that will work with Ubuntu 10.10.Does anyone know where I can download this?

View 1 Replies View Related

Software :: Return Value Of Expect Script?

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

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

Ubuntu :: Expect OOo Compatibility With Text-only .doc Files To Be Absolutely, 100% Perfect?

Jun 16, 2010

I encountered a doc file recently that opened noticeably differently in OOo than it did in MS Office. I think the difference was a small change in spacing that pushed some text onto the next line. It's also feasible that the problem was on my end. My question has this.

1. Should I expect OOo compatibility with text-only .doc files to be absolutely, 100% perfect?
2. If not, any insights on where the problems usually are?

View 1 Replies View Related

Ubuntu :: Store Expect Standard Output To Excel File?

Mar 16, 2011

I am working on telnet session and excuting commands. I am able to redirect or store expect output to log file but now i want to store in excel file like ispreadsheet showing details of commands and its responses

View 2 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 script.sh
#!/bin/bash
read -p "Username: " uname

[code]....

View 1 Replies View Related

Software :: Exit Expect If Prompt Does Not Match?

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

Software :: Using Expect To Execute Remote Commands?

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

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







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