LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-21-2010, 02:27 PM   #1
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Rep: Reputation: 16
i need to create a expect script to input username and password


i was able to input it directly from the script using this code

Code:
#!/usr/bin/expect -f

set USER "bibingeorge"
set PASS "bibin"
set HOST "192.168.3.249"

# connect via scp
spawn scp snd.tar.gz $USER@$HOST:
#######################
expect "${USER}@${HOST}'s password:"

send "${PASS}\r"

interact
how to do i read from a text file and store it in the variable
 
Old 03-21-2010, 03:56 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
not a networking question, moved to Linux - Newbie.
 
Old 03-21-2010, 04:52 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
That's a pretty nasty hack - why don't you use passwordless comms?
 
Old 03-22-2010, 01:57 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
This might be of help:

http://blogs.oracle.com/SanthoshK/20...p_command.html
 
Old 03-22-2010, 02:18 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And because I still think passwords in scripts are a really bad idea:
http://www.linuxquestions.org/linux/...ation_with_ssh
 
Old 03-22-2010, 04:48 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Usually when I start critisizing using expect with ssh, I generally seem to end up finding out that this is to an embedded system which doesn't support RSA keys or some such. So I dont bother complaining now!
 
  


Reply



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
how do i create a username and a password for squirrelmail? nibraz Linux - Server 3 10-11-2009 02:32 PM
expect script to change user password sherimm Linux - Software 1 03-13-2009 05:36 AM
Need help creating/using a password dialog box for an Expect script crazygyhrous Linux - General 1 12-13-2005 11:48 AM
bash script that uses username/password paul_mat Linux - Software 2 10-25-2005 10:44 PM
ow to create script change a user's password? passwd expects input from keyboard.. Arodef Linux - General 1 03-02-2005 10:40 PM

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

All times are GMT -5. The time now is 10:57 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