Subversion Repositories camp_sysinfo_client_3

Rev

Rev 251 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 251 Rev 253
Line 116... Line 116...
116
# checks if a command is valid on this system. If so, returns the full path to it
116
# checks if a command is valid on this system. If so, returns the full path to it
117
# else, returns empty string. Theoretically valid for Unix and Windows systems (tested Win10, Server 2019)
117
# else, returns empty string. Theoretically valid for Unix and Windows systems (tested Win10, Server 2019)
118
sub validCommandOnSystem {
118
sub validCommandOnSystem {
119
   my $command = shift;
119
   my $command = shift;
120
   # Windows uses 'where' while Unix uses which. Tested only on Windows Server
120
   # Windows uses 'where' while Unix uses which. Tested only on Windows Server
121
   $command = lc $^O eq 'mswin32' ? `where $command 2> /dev/null` : `which $command 2> /dev/null`;
121
   $command = lc $^O eq 'mswin32' ? `where $command 2> nul` : `which $command 2> /dev/null`;
122
   chomp $command;
122
   chomp $command;
123
   return -x $command ? $command : '';
123
   return -x $command ? $command : '';
124
}
124
}
125
 
125
 
126
# when passed a hashref containing the lower case of operating systems
126
# when passed a hashref containing the lower case of operating systems