LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2005, 10:02 AM   #1
bejiita
Member
 
Registered: Feb 2004
Location: Upstate NY
Distribution: Slackware
Posts: 79

Rep: Reputation: 15
yanbq yet another bash question


I use my laptop at home and @ work where both are running WEP and I have already written working scripts that connect me to either network
im trying to write a script that will decide which other script to call based on my input ive gotten this far and every time I keep running into errors. could someone please help.
im sure theres something im overlooking by far

#!/bin/bash -i
read -e -p "Where are you:"
if [$answer -eq 'home']; then
sh wlanH.sh
fi
exit 0
 
Old 09-05-2005, 10:48 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
You need spaces around [ and ].
 
Old 09-05-2005, 11:16 AM   #3
bejiita
Member
 
Registered: Feb 2004
Location: Upstate NY
Distribution: Slackware
Posts: 79

Original Poster
Rep: Reputation: 15
both sides of the braces, or inside/outside
 
Old 09-05-2005, 03:13 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
What happened when you tried?
 
Old 09-06-2005, 02:50 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, for strings, bash uses '=' eg http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-11.html and yes, spaces inside the square braces between each item and the braces themselves.
 
Old 09-06-2005, 08:50 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
how about:

Code:
select loc in home work;do
   case $loc in 
      home)
           echo blah home
           ;;
      work)
          echo blah work
          ;;
esac
break
done
a bit neater?

 
Old 09-06-2005, 08:56 AM   #7
bejiita
Member
 
Registered: Feb 2004
Location: Upstate NY
Distribution: Slackware
Posts: 79

Original Poster
Rep: Reputation: 15
hey thx man, I was thinkin may I should use a case statement rather than an if-then, thx ill let ya know
 
Old 09-06-2005, 08:59 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
pleasure
 
Old 09-06-2005, 09:03 AM   #9
bejiita
Member
 
Registered: Feb 2004
Location: Upstate NY
Distribution: Slackware
Posts: 79

Original Poster
Rep: Reputation: 15
it works thx
 
  


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
A question about BASH operand Linux - Newbie 2 11-27-2005 09:49 PM
BASH question robscott Linux - Software 3 11-23-2005 09:39 AM
Bash question lnxduck Programming 3 09-30-2005 08:50 AM
bash question? shanenin Linux - Software 1 11-26-2004 12:22 PM
little bash question gplacek Linux - General 2 09-01-2004 12:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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