Multiple commandline switches


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple commandline switches
# 1  
Old 02-16-2011
Multiple commandline switches

I have a script that has commandline switches that work no problem. But i don't know how to enable it to have multiple switches at one time. So I'd want

Code:
 myscript -h -o

or even
Code:
myscript -ho

but i'm having no luck incorporating this. I tried shifting but i'm not getting it. Thanks

---------- Post updated at 01:10 AM ---------- Previous update was at 12:57 AM ----------

just found getopts...think i found my answer
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read Strings in as options to switches

I have a script using getops with -a -t -l as potential switches, based on the switches used, it will set the respective variable value which will cause the routine/function to run. I need to also pass a string with the switch that will get parsed by the function. example ./myscript -a... (8 Replies)
Discussion started by: glev2005
8 Replies

2. Shell Programming and Scripting

Checking commandline

mymk target How to check is on commandline or no? Cannot to find out ;( Know that I need to use if.....new in shell sorry Please use code tags next time for your code and data. (2 Replies)
Discussion started by: Manueldo
2 Replies

3. AIX

LACP between AIX 7.1 and HP procurve switches

Hi. On a standalone AIX server, 7.1 version, I have 3 connected gigabit ethernet ports. I made an etherchannel like this : # lsattr -El ent4 adapter_names ent1,ent2 | EtherChannel Adapters True alt_addr 0x000000000000 | Alternate EtherChannel Address True auto_recovery yes | Enable... (1 Reply)
Discussion started by: stephnane
1 Replies

4. Shell Programming and Scripting

echo switches

Hello All, I am writing an shell script but abruptly its not able to recognize switches in echo statement. #!/bin/bash top -n 1 -b>ankit host=`hostname` time=`cat ankit|grep load|tr -s " "|cut -d " " -f3` load=`cat ankit|grep load|tr -s " "|cut -d "," -f4|cut -d ":" -f2` ... (3 Replies)
Discussion started by: ajaincv
3 Replies

5. Infrastructure Monitoring

Nagios monitoring for switches.

Hi, I have configured check_snmp plugin and using the plugin i am able to monitor the uptime of the switch. But the following fails # /usr/local/nagios/libexec/check_snmp -H 10.10.10.1 -C ready -o ifOperStatus.1 -r 1 -m RFC1213-MIB SNMP CRITICAL - *down(2)* | # Any suggestions ? (1 Reply)
Discussion started by: uxadmin007
1 Replies

6. Shell Programming and Scripting

Using curl in commandline

Hi, I am using curl to hit a url using http in solaris 10 using commandline, I want to transfer an attachment(using multipart curl -F) also as a part of the request. If anyone has used kindly help me with the syntax. I am using below command: /usr/local/bin/curl -v... (1 Reply)
Discussion started by: manishmaha
1 Replies

7. Shell Programming and Scripting

Collect information from switches

Hi All , In my environment we have 12 SAN switches .Culd u pls help me for below queries . would like to telnet to all switches and collect information in daily basis with "switchstatus" command and store the output under /tmp/ folder on systemA . To keep passwords of 12switches in a... (1 Reply)
Discussion started by: chinni-script
1 Replies

8. Programming

Signal Handling and Context Switches

Hi guys, this is my first posting, so at first hi to everyone! ;) I have a problem with ucontext_t in connection with signal handling. I want to simulate a preemptive scheduler. I am using the iTimer with ITIMER_PROF, to schedule the interrupts. You find the code below: #include <stdio.h>... (18 Replies)
Discussion started by: XComp
18 Replies

9. UNIX for Advanced & Expert Users

Tar switches!!!

Hi, If i want to write my data on several tapes, (more than one tape), what switch(s) i need to use with tar. In other word if my data needs the sapce more than one tape & i don't wanna to compress or ... my data. so is it possible to write up to the end of the tape & it asks to put another... (1 Reply)
Discussion started by: nikk
1 Replies
Login or Register to Ask a Question
Getopt::Std(3pm)					 Perl Programmers Reference Guide					  Getopt::Std(3pm)

NAME
getopt, getopts - Process single-character switches with switch clustering SYNOPSIS
use Getopt::Std; getopt('oDI'); # -o, -D & -I take arg. Sets $opt_* as a side effect. getopt('oDI', \%opts); # -o, -D & -I take arg. Values in %opts getopts('oif:'); # -o & -i are boolean flags, -f takes an argument # Sets $opt_* as a side effect. getopts('oif:', \%opts); # options as above. Values in %opts DESCRIPTION
The getopt() function processes single-character switches with switch clustering. Pass one argument which is a string containing all switches that take an argument. For each switch found, sets $opt_x (where x is the switch name) to the value of the argument if an argument is expected, or 1 otherwise. Switches which take an argument don't care whether there is a space between the switch and the argument. The getopts() function is similar, but you should pass to it the list of all switches to be recognized. If unspecified switches are found on the command-line, the user will be warned that an unknown option was given. The getopts() function returns true unless an invalid option was found. Note that, if your code is running under the recommended "use strict 'vars'" pragma, you will need to declare these package variables with "our": our($opt_x, $opt_y); For those of you who don't like additional global variables being created, getopt() and getopts() will also accept a hash reference as an optional second argument. Hash keys will be x (where x is the switch name) with key values the value of the argument or 1 if no argument is specified. To allow programs to process arguments that look like switches, but aren't, both functions will stop processing switches when they see the argument "--". The "--" will be removed from @ARGV. "--help" and "--version" If "-" is not a recognized switch letter, getopts() supports arguments "--help" and "--version". If "main::HELP_MESSAGE()" and/or "main::VERSION_MESSAGE()" are defined, they are called; the arguments are the output file handle, the name of option-processing package, its version, and the switches string. If the subroutines are not defined, an attempt is made to generate intelligent messages; for best results, define $main::VERSION. If embedded documentation (in pod format, see perlpod) is detected in the script, "--help" will also show how to access the documentation. Note that due to excessive paranoia, if $Getopt::Std::STANDARD_HELP_VERSION isn't true (the default is false), then the messages are printed on STDERR, and the processing continues after the messages are printed. This being the opposite of the standard-conforming behaviour, it is strongly recommended to set $Getopt::Std::STANDARD_HELP_VERSION to true. One can change the output file handle of the messages by setting $Getopt::Std::OUTPUT_HELP_VERSION. One can print the messages of "--help" (without the "Usage:" line) and "--version" by calling functions help_mess() and version_mess() with the switches string as an argument. perl v5.12.1 2010-04-26 Getopt::Std(3pm)