Can I write a program to gather parameters in order to generate script to guide a binary file installation [closed]

StackOverflow https://stackoverflow.com/questions/18052962

  •  23-06-2022
  •  | 
  •  

Question

OK, just as concept:

The base platform is Suse Enterprise server 11.1

I have a binary file to install; to install it, I need input some value such as ip address, cert location and so on.

Now what I want to do is to write a perl program to gather all input information first and then generate a script to guide the binary file install unattended.

Can it be done? I'm a fresh Perl learner.

Thanks.

Was it helpful?

Solution

The easiest way to get paramters via Console, is to use the Getopt Module. You can find further informations about that here:

For example:

use Getopt::Long;
my $data = "bin_file";
my $length = 24;
my $verbose;
GetOptions ("length=i" => \$length, # numeric
"file=s" => \$data, # string
"verbose" => \$verbose
) # flag
or die("Error in command line arguments\n");

Then you can call your script (inside your shell) with:

$ perl script.pl --length 14 --file test.dat --verbose

Getopt parses the command line from @ARGV , recognizing and removing specified options and their possible values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top