in reply to perl script that accepts parameters via STDIN
Welcome to the Monastery, mbravismore!
Normally, I'd skip such a question due to no effort shown whatsoever (please do so in the future), but I thought I'd at least show a basic skeleton that you can at least get started with. See the documentation of Getopt::Long to get an understanding of what is happening. You'll want/need to add in some parameter checking to ensure all required arguments are passed in.
use strict; use warnings; use Getopt::Long; my %args; GetOptions ( 'i|txtpatid=s' => \$args{txtpatid}, 'p|txtpatpw=s' => \$args{txtpatpw}, 's|txtpatserver=s' => \$args{txtpatserver}, ); for (keys %args){ print "$_: $args{$_}\n"; }
Run it:
perl script.pl -i stevieb -p secret -s user
Output:
txtpatid: stevieb txtpatpw: secret txtpatserver: user
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl script that accepts parameters via STDIN
by LanX (Saint) on Nov 29, 2016 at 13:31 UTC | |
by haukex (Archbishop) on Nov 29, 2016 at 13:43 UTC | |
by stevieb (Canon) on Nov 29, 2016 at 13:37 UTC |