The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Switch abey High Level Programming 12 06-27-2006 07:11 PM
switch user inside a script nimo Shell Programming and Scripting 2 11-04-2005 07:51 AM
switch from csh to ksh veeracer Shell Programming and Scripting 8 11-05-2004 02:13 PM
switch from csh to ksh veeracer UNIX for Dummies Questions & Answers 1 11-03-2004 06:28 PM
can you switch neer45 Shell Programming and Scripting 3 12-05-2001 08:54 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2007
Del33t Del33t is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 2
script with more then one switch

Hi, have managed to code a script that has a simple menu so for instance if I run:

Quote:
./theprogram.sh -h
this will call a help function that displays the programs help, I have coded this in using a case statement so if: case is h) call the help function

The problem is I don't know how to code in the functionality for more then one switch on the same line!

this is what i mean:

Quote:
./theprogram.sh -f acces.log -s ip
In the above the program has two switches -f is file so the program knows where the file is which is access.log and -s is the sort option and I want it to sort the access.log file by ip

Basically the program essentially modifys how a squid log file looks , so for eg you can list the log from a-z based on hostname would be one functionality.

Any ideas? I am really stuck.
  #2 (permalink)  
Old 08-29-2007
Del33t Del33t is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 2
kinda worked it out using $1 $2 etc.
  #3 (permalink)  
Old 08-29-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You should use getopts if you are planning to handle a lot of arguments. It will make things a lot easier.
  #4 (permalink)  
Old 08-29-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
YOu can code is it using the function GETOPTS and OPTARGS. GETOPTS will check for the flags, and OPTARGS will get the arguments for that flags.

Last edited by ahmedwaseem2000; 08-29-2007 at 02:53 AM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On



All times are GMT -4. The time now is 01:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0