nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

passing options to a shell script

This is a discussion on passing options to a shell script within the Shell scripting forums, part of the Development/Scripting category; Hi, im trying to write a script (on Solaris) that will accept two options out of a list of 5 ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 16-09-2007, 11:32 PM
Junior Member
User
 
Join Date: Sep 2007
OS: Solaris/FreeBSD
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
bigpaw is on a distinguished road
Send a message via MSN to bigpaw Send a message via Yahoo to bigpaw
Default passing options to a shell script

Hi,

im trying to write a script (on Solaris) that will accept two options out of a list of 5 options. The first set of options comprise --test, --real and --
verbose, the second set of options comprises --months and --year and
of which each it takes a numerical variable greater than 0.

What i am trying to accomplish is, when any one of the first set of
variables is passed, a second from that set cannot be passed, and when
an attempt to pass more than one option from the first set an error is
given. the same applies to the second set of options.

I am using getopts to get the options, but failed to find a way to
restrict usage of only one option from the two sets of options.

any guidance appreciated.

Regards,

Mike
Reply With Quote
  #2 (permalink)  
Old 24-09-2007, 08:21 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You can see this script : http://www.cyberciti.biz/files/scrip...in-check-2.txt

It has example which will help you out
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 11-10-2007, 02:40 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
praveenmall
Default

Can you please your shell script?

Thanks,
Praveen
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to verify the options used when mounting a nfs FS. warren Solaris/OpenSolaris 5 30-04-2009 05:56 PM
SSH - Passing Unix login passwords through shell scripts arulkumarr Shell scripting 4 27-08-2008 09:22 PM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 08-10-2007 12:36 AM
Certification options !!! donovan The Hangout 14 30-05-2007 04:48 AM
Passing value from variable while its expected from keyboard unix11 Shell scripting 3 22-02-2007 02:36 PM


All times are GMT +5.5. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

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 33 34 35 36 37 38