LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-08-2005, 02:59 PM   #1
moosedaddy
Member
 
Registered: Feb 2003
Location: Oklahoma
Distribution: Debian Unstable
Posts: 244

Rep: Reputation: 30
Please help with interactive script


I have a laptop and when I boot I disable both the built in wireless and the on board lan. I need a script that will ask if I want wireless started (dhclient wlan0) if so load ndiswrapper and have an option to enter the encryption key or start the lan (dhclient eth0).

I would like something similar to what I have below.

#!/bin/bash

echo "Start wireless?"
read WIRELESS
if $WIRELESS = N; then dhclient eth0
if $WIRELESS = Y; then modprobe ndiswrapper
echo "Enable Encryption?"
read KEY
if $KEY = N; then dhclient wlan0
if $KEY = Y; then iwconfig wlan0 key xxxxxxxxx
dhclient wlan0

Any and all help would be appreciated!
 
Old 12-08-2005, 06:34 PM   #2
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
moosedaddy,

I just hacked this up together so I'm not sure if it will work or not. Hopefully it will get you on your way though.

Code:
#!/bin/bash
echo -n "Start wireless? (Y/N)"
read wireless
if [ "$wireless" = "N" ]; then
        dhclient eth0
elif [ "$wireless" = "Y" ]; then
        modprobe ndiswrapper
fi
echo -n "Enable Encryption? (Y/N)"
read key
if [ "$key" = "N" ]; then
        dhclient wlan0
elif [ "$key" = "Y" ]; then
        iwconfig wlan0 key xxxxxxxxx && dhclient wlan0
fi
Good luck,
Kristijan
 
Old 12-08-2005, 09:47 PM   #3
moosedaddy
Member
 
Registered: Feb 2003
Location: Oklahoma
Distribution: Debian Unstable
Posts: 244

Original Poster
Rep: Reputation: 30
Thanks that worked just as I wanted.
 
Old 12-08-2005, 10:02 PM   #4
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
moosedaddy,

Your welcome!

However, the script is case sensitive. So if you enter 'y' instead of 'Y', it won't work. It's not to hard to fix it, but I'm at work at the moment.

Let me know if you want it adjusted, or better yet, google for some bash scripting tutorials and have a go at it yourself.

Cheers,
Kristijan
 
  


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
non-interactive ssh podollb Linux - Software 3 04-20-2004 04:28 PM
interactive CD and WINE santiagosilva Linux - Software 0 03-31-2004 07:17 PM
Interactive setup EECGeek Linux - Newbie 4 01-20-2004 10:15 PM
Non interactive FTP lapthorn Linux - Networking 1 11-28-2003 01:05 PM
Non interactive FTP lapthorn Linux - Networking 1 11-25-2003 05:00 AM


All times are GMT -5. The time now is 02:27 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration