Subversion Repositories camp_sysinfo_client_3

Rev

Rev 69 | Rev 117 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 69 Rev 116
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
use warnings;
2
use warnings;
3
use strict;  
3
use strict;  
4
 
4
 
-
 
5
# modified 20190419 RWR
-
 
6
# changed cleanup to remove encapsulating quotes
-
 
7
 
5
# Description: Library used by modules. Do NOT enable
8
# Description: Library used by modules. Do NOT enable
6
 
9
 
-
 
10
 
7
our $VERSION = '1.2';
11
our $VERSION = '1.3';
8
 
12
 
9
# set of libraries to be used by these modules
13
# set of libraries to be used by these modules
10
 
14
 
11
 
15
 
12
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
16
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
13
#           chomps the string (removes trailing newlines)
17
#           chomps the string (removes trailing newlines)
14
#           removes all text BEFORE the delimiter, the delimiter, and any whitespace
18
#           removes all text BEFORE the delimiter, the delimiter, and any whitespace
15
#           thus, the string 'xxI Am x  a weird string' with a newline will become
19
#           thus, the string 'xxI Am x  a weird string' with a newline will become
16
#           'a weird string' with no newline
20
#           'a weird string' with no newline
-
 
21
# will also look for single and double quotes surrounding entire string and remove them
-
 
22
# if they exisst
17
 
23
 
18
sub cleanUp {
24
sub cleanUp {
19
   my ($delimiter, $text) = @_;
25
   my ($delimiter, $text) = @_;
20
   chomp $text;
26
   chomp $text;
-
 
27
   if ( $text =~ m/[^$delimiter]*$delimiter\s*(.*)/ ) {
-
 
28
      $text = $1;
-
 
29
   }
21
   return $text unless $delimiter;
30
   if ( $text =~ m/^'(.*)'$/ ) {
-
 
31
      $text = $1;
-
 
32
   }
22
   $text =~ m/[^$delimiter]*$delimiter\s*(.*)/;
33
   if ( $text =~ m/^"(.*)"$/ ) {
-
 
34
      $text = $1;
-
 
35
   }
23
   return $1;
36
   return $text;
24
}
37
}
25
 
38
 
26
# checks if a command is valid on this system. If so, returns the full path to it
39
# checks if a command is valid on this system. If so, returns the full path to it
27
# else, returns empty string.
40
# else, returns empty string.
28
sub validCommandOnSystem {
41
sub validCommandOnSystem {