troubleshooting Question

Multiple Parameters

Avatar of Simon336697
Simon336697Flag for Australia asked on
PerlScripting Languages
8 Comments1 Solution200 ViewsLast Modified:
Hi guys hope you can help.
Id like to be able to do build the following script that does the following.. -b <business> -s <scope>  -n <remote file> -f <filename>
<business>, <scope>, <remote file> and <filename> are parameters that are entered in by the user.

Options available would be:

<business>:      -b
"L" --- (for liquor),   # any systems in <filename> that start with the letter "l"
"S" --- (for store),   # any systems in <filename> that start with the letter "s"
"O" --- (for other)   # any systems in <filename> that start with the letter "o"

<scope>:           -s
"A" --- (for all systems in <filename> as defined by the -b switch eg. if user puts in "L" for the -b switch, and "A" for the s switch, then all ("A") liquor systems as defined in <filename> (as entered at the command line for the -f switch), would be processed),  
"S" --- (for systems ending in "NT001" in <filename>),
"N" --- (for systems that DONT end in "NT001" in <filename>)

<remote file>:      -n
a supplied full LOCAL path and file to the file you wish to check the existence for.

<filename>:        -f
a supplied name of a file that has a list of computers in it, 1 computer per line.
This file will be processed based on the criterion of the aforementioned switches, in order for filtering of machines in <filename>.

So, an example of user input to run the script would be: -b L -s A -n "d:\bin\testfile.txt" -f systems.txt

What the above would do is:
1) Read the systems.txt file (as defined by -f <filename>
2) Search for the business "L" - any systems that start with "L" (as defined by -b <business)
3) Grab ALL systems that start with "L" - all because of the -s A (as defined by -s <scope>)
4) Check for the existence of "d:\bin\testfile.txt" on the remote system (as defined by -n <remote file>)
5) If the file exists, write to a file called "fileexists.txt" with an entry for the computer name.
6) If the file doesnt exist, write to a file called "filenotexists.txt" with an entry for the computer name.
7) The user should be able to miss some of the parameters, thus being able to do the following: -n "d:\bin\testfile.txt" -f systems.txt

In which case, the script would read the systems.txt file, process every system in systems.txt, disregarding the -b and -s switches, and search for the existence of "d:\bin\testfile.txt" on the remote machine.

As the entry for the -n switch is inputted as local eg."d:\bin\testfile.txt", the d: has to be interpreted as a d\$
In other words, when a computer name is read from the <filename>, for example, LR2313NT001, when checking for the file existence, the path is \\\\$SystemName\\d\$\\bin\testfile.txt, if $SystemName is chosen as the variable name to set for the computers in <filename>.

I know how to do the code to connect to each machine, but the code for the multiple parameters is overwhelming, and any help appreciated.

This question will probably go over 2 questions, as I know there is a lot here.

Thanks guys.
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros