LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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
  Search this Thread
Old 08-09-2012, 10:22 AM   #1
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 9

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, 10:25 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,309

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ 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, 10: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 10:27 AM.
 
Old 08-10-2012, 02:02 AM   #4
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 9

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, 11: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 11:35 PM.
 
1 members found this post helpful.
Old 08-14-2012, 06:03 AM   #6
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 9

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



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 10:06 PM
Issue in running commands in expect script from shell script yadvinder Programming 0 05-31-2012 05:07 AM
Very Basic expect script - What am I missing? Mikey0727 Programming 1 10-07-2010 10:12 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-28-2010 12:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration