03-07-2014
Could you point out where in the manual page it shows that getopts treats arguments as switches (+x / -x) and not options (-x)?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I have a KornShell script that has successfully been scheduled through Cron. We are in the process of changing over from Cron to using CA-Unicenter. To negative test the script I put a bad return code in. At the bottom of the script an e-mail is sent using mailx and then the return code is set... (1 Reply)
Discussion started by: Connie
1 Replies
2. Shell Programming and Scripting
I need a KornShell script that will, among all the users currently logged on to the system, find a slot of one hour that contains the most number of users. I know how to list all the users currently logged on but how do I do anything with the times that are listed? Please help, thanks. (1 Reply)
Discussion started by: ckrieger1
1 Replies
3. Shell Programming and Scripting
Hello everybody,
Is there any way to make a script (Bash, KornShell, etc.) executable
by mouse clicking?
For example you have a file myscript.sh, you run:
$ chmod u+x myscript.sh
Therefore it becomes executable and all you need is to run from
the terminal:
$./myscript.sh... (2 Replies)
Discussion started by: dariyoosh
2 Replies
4. Shell Programming and Scripting
Dear all,
I have created a KornShell script containing swiches with getopts (command line switches). Normally, my script should work like this:
$ ./myscript.ksh -a 12 -b 4 -c 78
The switch a was selected with the argument 12
The switch b was selected with the argument 4
The switch c was... (3 Replies)
Discussion started by: dariyoosh
3 Replies
5. Shell Programming and Scripting
Hi,
I'm a novice at programming and need some help with a kornshell script I've been writting.
I have an inputdirectory with all my .shp files. In my input directory the shapefiles are named XXXX_original.shp, XXXX_UPDATE.shp ect.
In my .ksh script I have created a for loop which... (2 Replies)
Discussion started by: beery
2 Replies
6. Shell Programming and Scripting
Hello
Can someone help me to write a perl script or kornshell reading a two files and outputting to comma format.
Here is the two files
listofdisks.txt
id, diskname, diskgroup, diskisze(GB), FC
1, CN34, GRP1, 30, FC_CN34
2, CN67, GRP5, 19,
4, VD1, GRP4, 23, FC_VD1
6, CF_D1, ... (0 Replies)
Discussion started by: deiow
0 Replies
7. AIX
Hi all,
I'm having a problem here my environment as follows.
AIX 5.3 TL 10 running on a P6 p520 sever with 3 fibre channel cards and Tivoli Storage Manager TSM 5.4 and TS3200 Tape Library with 2 drives and 2 media changers.
My problem as follows smc1 doesn't show up , I ran cfgmgr multiple... (6 Replies)
Discussion started by: h@foorsa.biz
6 Replies
8. AIX
Hi all,
I have a problem here
root@host1 / # lsdev -Cc tape
rmt0 Defined 07-00-02 IBM 3580 Ultrium Tape Drive (FCP)
rmt1 Defined 07-00-02 IBM 3580 Ultrium Tape Drive (FCP)
smc0 Defined 07-00-02 IBM 3573 Tape Medium Changer (FCP)
root@host1 / # cfgmgr -l fcs2
Method error... (2 Replies)
Discussion started by: h@foorsa.biz
2 Replies
9. Ubuntu
I have Ubuntu 16.04 (dual boot with Windows 10) and a HP Spectre x360 laptop.
I have recently bought a Dell Ultrasharp U2515H monitor, which I connect via a Dell docking station.
When I plug the docking station to my laptop on Windows, both monitors are detected and everything works fine.
... (23 Replies)
Discussion started by: twelth_hour
23 Replies
10. Hardware
I have a Dell XPS M1330 laptop. The OS is Windows 10. I had to replace the motherboard because it was bad. After replacing the motherboard I noticed the optical (DVD/CD) drive is neither detected in BIOS and OS nor making any noise at all. Everything else seems to be working fine. The optical drive... (3 Replies)
Discussion started by: milhan
3 Replies
LEARN ABOUT OSX
getopt::std
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.16.2 2012-10-11 Getopt::Std(3pm)