LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-03-2005, 06:55 PM   #1
djcham
LQ Newbie
 
Registered: Feb 2005
Posts: 17

Rep: Reputation: 0
passwords in shell scripts


hello!

i'm trying to write a script that will run a bunch of tests for me by transferring files using SCP.

I would like to write a script that will SCP, then enter my password and repeat. How do i write a code that wil wait for a prompt and then enter a password? Thanks a lot!
 
Old 10-03-2005, 07:03 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Edit: sorry, that puts it in automatically, and you want to put it in manually.

Well, now I don't know if this is what you have in mind or not.

Here's part of an ftp script using expect.

#!/usr/bin/expect -f

spawn ftp -i 192.168.0.1
expect "Name"
send "fred\r"
expect "Passsword:"
send "mypassword\r"

Last edited by homey; 10-03-2005 at 07:07 PM.
 
Old 10-03-2005, 07:21 PM   #3
djcham
LQ Newbie
 
Registered: Feb 2005
Posts: 17

Original Poster
Rep: Reputation: 0
thanks "homey" haha...

i'll try it out...

is "expect" a command you can use for any program when waiting for a prompt?..i guess so?
 
Old 10-03-2005, 08:53 PM   #4
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Re: passwords in shell scripts

Quote:
Originally posted by djcham
I would like to write a script that will SCP, then enter my password and repeat. How do i write a code that wil wait for a prompt and then enter a password? Thanks a lot!
You would be better off using keys for your authentication. Read up on how to generate keys for SSH and ssh-agent.
 
Old 10-04-2005, 01:57 AM   #5
ns_sanish
LQ Newbie
 
Registered: Jun 2004
Posts: 9

Rep: Reputation: 0
expect is the answer. If u havent done this b4, then better experiment with auto-expect which generates an expect script based on ur terminal activity.

1) run auto-expect.
2) do some activity. (ex: telnet to a machine and login and do an ls or somerthing)
3) exit (exits from auto-expect)
4) ls -ltr, last file is ur except script. run it
 
  


Reply


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
Need shell script to set passwords for already created users naren_0101bits Programming 2 08-28-2005 02:02 PM
I Need shell scripts flyyy_82 Linux - Security 1 01-27-2005 04:05 PM
shell scripts rocketgo Linux - General 10 12-01-2003 05:20 AM
shell scripts... roofy Linux - Newbie 13 05-06-2003 06:06 PM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM


All times are GMT -5. The time now is 08:54 AM.

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