Say Hello! Networking for Professionals
Register Get Password Search Today's Posts Mark Forums Read
Join the Discussion

Not a member yet? Register for FREE!
Go Back   Join the Discussion / Discussion Groups / Computers & Gadgets
Reload this Page Enter a password automatically w/ bash script?

Computers & Gadgets A great place to discuss computers, gadgets and the internet. PC, laptop, firefox, ie, linux, mac, ipods, digital cameras and more.

JOIN TODAY! It's FREE . . . Discuss topics and issues that matter to you!

8,000 active members posting their views, facts and opinions on issues and topics that are important to people of today.

Join a Discussion or better yet and Start a Discussion of your own!

Reply
 
Thread Tools
Old 08-10-2007   #1 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Enter a password automatically w/ bash script?

I have a script.
Code:
#!/bin/bash
if iwlist eth0 scanning | grep -q 'ESSID1'
then iwconfig eth0 essid ESSID1 key WEP-KEY && dhclient eth0
elif iwlist eth0 scanning | grep -q 'ESSID2'
then iwconfig eth0 essid ESSID2 && iu-vpn-ipsec start
fi
iu-vpn-ipsec asks for a password. I want this script to run when the computer starts, so I don't want to have to enter the password manually. Does anyone know how get my script to enter the password for me?

P.S. I also asked on ubuntuforums, but haven't gotten a positive answer yet.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-11-2007   #2 (permalink)
hairy_Palms
Chuck Norris
 
hairy_Palms's Avatar
 
Join Date: May 2007
Location: London, England
Posts: 330
Default Re: Enter a password automatically w/ bash script?

i can only recommend what i use for sudo, i use
Code:
echo "password" | sudo -S insertcommandhere
which id guess for you would be
Code:
echo "password" | iu-vpn-ipsec start
http://www.venganza.org/about/open-letter/
"Creationism is not a scientific alternative to natural selection any more than the stork theory is an alternative to sexual reproduction." — Hayes, 1996.
hairy_Palms is offline   Reply With Quote
Old 08-11-2007   #3 (permalink)
c.dric
Agitator
 
c.dric's Avatar
 
Join Date: May 2007
Location: a pale blue dot
Posts: 635
Default Re: Enter a password automatically w/ bash script?

Quote:
Originally Posted by hairy_Palms View Post
i can only recommend what i use for sudo, i use
Code:
echo "password" | sudo -S insertcommandhere
which id guess for you would be
Code:
echo "password" | iu-vpn-ipsec start
that's good to know ... i was looking for a way to do that a few weeks ago.
I'm a simple man with complex tastes. (Calvin & Hobbes)
>> http://c.dric.be/gium >> http://bookmarks.c.dric.be/
c.dric is offline   Reply With Quote
Old 08-11-2007   #4 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Re: Enter a password automatically w/ bash script?

Well, it doesn't work in my case. It gives me
Code:
stty: standard input: Invalid argument
Thanks though.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-11-2007   #5 (permalink)
yaaarrrgg
Eligible for a custom title
 
yaaarrrgg's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 791
Default Re: Enter a password automatically w/ bash script?

for complex interactive tools, the "expect" tool is probably the most powerful.

Otherwise for simple scripts you can do something like:

sudo umount /media/disk << eob
YOURPASSWORD
eob


(the eob just marks a "here" document ... can be any unique string)
yaaarrrgg is offline   Reply With Quote
Old 08-11-2007   #6 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Re: Enter a password automatically w/ bash script?

Quote:
Originally Posted by yaaarrrgg View Post
for complex interactive tools, the "expect" tool is probably the most powerful.
Yeah, I think "expect" is going to be the way to go. A guy suggested it on ubuntuforums. It's kinda more advanced than I am though, so I'll have to spend some time learning how to make it work. If you know a beginner's tutorial for it, I'd appreciate it if you'd link it.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-11-2007   #7 (permalink)
yaaarrrgg
Eligible for a custom title
 
yaaarrrgg's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 791
Default Re: Enter a password automatically w/ bash script?

this tutorial seems to cover most things you'd need.

http://floppsie.comp.glam.ac.uk/Glam...ripting/5.html

it probably looks worse than it really is, but the two main commands are just 'send' and 'expect'
yaaarrrgg is offline   Reply With Quote
Old 08-11-2007   #8 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Re: Enter a password automatically w/ bash script?

Thanks, yaarrrggg. I'll give it a look.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-11-2007   #9 (permalink)
hairy_Palms
Chuck Norris
 
hairy_Palms's Avatar
 
Join Date: May 2007
Location: London, England
Posts: 330
Default Re: Enter a password automatically w/ bash script?

that looks a more elegant solution than echo and pipe i might have to look into that myself ^^
http://www.venganza.org/about/open-letter/
"Creationism is not a scientific alternative to natural selection any more than the stork theory is an alternative to sexual reproduction." — Hayes, 1996.
hairy_Palms is offline   Reply With Quote
Old 08-11-2007   #10 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Re: Enter a password automatically w/ bash script?

Beautiful. I think it worked. I won't know for sure until I try it at school, but it looks like it's working. Thanks.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-15-2007   #11 (permalink)
javaJake
Discussion starter
 
javaJake's Avatar
 
Join Date: May 2007
Location: Eastern Coast, USA
Posts: 76
Send a message via AIM to javaJake Send a message via MSN to javaJake Send a message via Yahoo to javaJake
Default Re: Enter a password automatically w/ bash script?

As always, keep in mind the security risks behind these methods. They all require the password to be pre-stored somewhere. Make sure no one but trusted people can even touch the file containing your root password.

You probably already knew this, but someone has to say it.
Quote:
For then there will be great distress, unequaled from the beginning of the world... and never to be equaled again. If those days had not been cut short, no one would survive, but for the sake of the elect those days will be shortened.
Are you ready?
javaJake is offline   Reply With Quote
Old 08-15-2007   #12 (permalink)
bns
Moderator
 
bns's Avatar
 
Join Date: May 2007
Location: Indiana, USA
Posts: 1,648
Default Re: Enter a password automatically w/ bash script?

Quote:
Originally Posted by javaJake View Post
As always, keep in mind the security risks behind these methods. They all require the password to be pre-stored somewhere. Make sure no one but trusted people can even touch the file containing your root password.

You probably already knew this, but someone has to say it.
Thanks for the obligatory security comment. I wouldn't do it on a computer that others could get to; it's on my laptop that stays with me. So if you want to access my computer, you need to beat me up first ... and if you do that, frankly my password is the least of my worries.
"Give a man fire, and he will be warm for a day; set a man on fire and he will be warm for the rest of his (short) life."---Wofl
bns is offline   Reply With Quote
Old 08-15-2007   #13 (permalink)
javaJake
Discussion starter
 
javaJake's Avatar
 
Join Date: May 2007
Location: Eastern Coast, USA
Posts: 76
Send a message via AIM to javaJake Send a message via MSN to javaJake Send a message via Yahoo to javaJake
Default Re: Enter a password automatically w/ bash script?

Quote:
Originally Posted by bns View Post
Thanks for the obligatory security comment. I wouldn't do it on a computer that others could get to; it's on my laptop that stays with me. So if you want to access my computer, you need to beat me up first ... and if you do that, frankly my password is the least of my worries.
Yea, your clients won't be happy about their SS#'s...
Quote:
For then there will be great distress, unequaled from the beginning of the world... and never to be equaled again. If those days had not been cut short, no one would survive, but for the sake of the elect those days will be shortened.
Are you ready?
javaJake is offline   Reply With Quote
Reply


Thread Tools



All times are GMT -5. The time now is 06:19 PM.



vBulletin® Version 3.6.7. Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32