LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 08-09-2012, 09:22 AM   #1
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Rep: Reputation: 0
something missing in my expect script


Hi,
I am trying hard on getting this done.
This is the first time i am using a expect script.

Here is a simplified way of what i am trying to use via expect.

Code:
ssh localhost
expect assword:
send "password\r"
and, the o/p is

Code:
[root@centos 4.0.10]# ./test2
root@localhost's password:
The problem here is that it is not inputting the password value at the prompt.
it is just waiting for the user to input and hence the expect is not doing what it's supposed to.

Any idea, What am i missing here.

Thanks in advance.
Any help appreciated.
 
Old 08-09-2012, 09:25 AM   #2
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,552

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
^ if your using expect to use passwordless login via ssh then you are going about it the wrong way. look up ssh with keys. your definately going about it the wrong way if you are trying to login remotely into the root account.
 
Old 08-09-2012, 09:26 AM   #3
kenneth_phough
Member
 
Registered: Dec 2005
Location: Birmingham, AL
Distribution: CentOS, REHL, Vine Linux
Posts: 67

Rep: Reputation: 3
Your script is looking for "assword" not "root@localhost's password:"

try
Quote:
expect "*?assword:*"
in place of your current expect.

this will help: http://bash.cyberciti.biz/security/e...-login-script/

And agreed with schneidz. If passwordless login is all you are looking for definitely look into ssh with keys

Last edited by kenneth_phough; 08-09-2012 at 09:27 AM.
 
Old 08-10-2012, 01:02 AM   #4
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks folks.
Well, i am not actually using ssh in my script.
as i mentioned before, i just put that to simplify it.
Actually, i have a tool which runs and prompts for users to input values (similar to how ssh waits for user input).

Quote:
expect "*?assword:*"
I tried it but it still does not accept the value.

Thanks
 
Old 08-10-2012, 10:31 PM   #5
kenneth_phough
Member
 
Registered: Dec 2005
Location: Birmingham, AL
Distribution: CentOS, REHL, Vine Linux
Posts: 67

Rep: Reputation: 3
How are you running the script?
The following script work for me, could you give that a try and let us know the results? (replacing some_host and some_password with a real host and password for a ssh user)

Filename: testscript
Quote:
#!/usr/bin/expect
spawn ssh root@192.168.1.3
expect "*?assword:"
send "VolunteerExp06012013\r"
interact
Execute in command line:
Quote:
$ expect testscript

Last edited by kenneth_phough; 08-10-2012 at 10:35 PM.
 
1 members found this post helpful.
Old 08-14-2012, 05:03 AM   #6
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks a lot.
It's working.
I was missing the "interact".

Thanks again.
 
  


Reply

Tags
expect, shell, shell script, shell scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
Issue in running commands in expect script from shell script yadvinder Programming 0 05-31-2012 04:07 AM
Very Basic expect script - What am I missing? Mikey0727 Programming 1 10-07-2010 09:12 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM


All times are GMT -5. The time now is 08:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration