Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-13-2014, 06:18 PM   #1
LQ Newbie
Registered: Aug 2014
Posts: 5

Rep: Reputation: Disabled
Need help with shell scripting

Hello guys,

Ive just started using shell scripting again after a long time. just hoping you could help on this.

I'm trying to create a script using a menu with multiple options.
Enter company ID:

echo "[1] HR21"
echo "[2] c21connect"
echo "[3] MHR21"
Select all products that applies:
it will then create a conf using the company Id ,eg AAA_conf.

I have a template file for each product like:
location /c21p/ {
(commads here)

This temp.txt will then be embedded to the specific area in the AAA_conf file
Old 08-13-2014, 10:49 PM   #2
Senior Member
Registered: Sep 2010
Location: Wellington, New Zealand
Distribution: Slackware, Fedora
Posts: 1,015

Rep: Reputation: 663Reputation: 663Reputation: 663Reputation: 663Reputation: 663Reputation: 663
I think there might be an argument here that it would be more unix-y if you skipped the menu and just made the input go something like this:

Code: --hr21 --c21connect --mhr21 Acme
But obviously that's up to you. Even so, that's the example I'm going to provide and it should give you a rough idea how to parse the info:


while [ True ]; do
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo " "
echo " [--mhr21|--c21connect|--hr21] company"
echo " "
elif [ "$1" = "--mhr21" -o "$1" = "-m" ]; then
shift 1
elif [ "$1" = "--c21connect" -o "$1" = "-c" ]; then
shift 1
elif [ "$1" = "--hr21" -o "$1" = "-r" ]; then
shift 1


echo ${ITEM[1]}
echo ${ITEM[2]}
echo ${ITEM[3]}
echo ${ITEM[4]}

# create conf file
touch ${ITEM[4]}.conf
echo "#BEGIN C21CONNECT" >> ${ITEM[4]}.conf
echo "location /c21p/ {" >> ${ITEM[4]}.conf
echo  ${ITEM[1]}  ${ITEM[2]} ${ITEM[3]} >> ${ITEM[4]}.conf
echo "}" >> ${ITEM[4]}.conf

echo "all done i think"
Hope that helps.
Old 08-14-2014, 01:29 AM   #3
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,562

Rep: Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810Reputation: 2810
probably you can try the built-in select command (of bash).


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
LXer: Shell Scripting: Really Programming The Shell LXer Syndicated Linux News 0 02-28-2014 02:40 PM
win32,shell code,shell programming,shell scripting? mr.cracker Linux - Newbie 4 07-12-2013 11:20 PM
LXer: Terminal functions for shell scripting with Shell Curses LXer Syndicated Linux News 0 03-26-2008 11:50 PM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration