What is the differnce between System and System::Execute in Perl?

I am not a perl expert but in maintaining code, I am seeing System::Execute.  I am do not know what the command !System::Execute($cmd) does or rather System::Execute.  
I am also wondering what is the difference between using System($cmd) and System::Execute($cmd)

One example is:
if (!System::Execute($cmd))
{
      $::ErrorMessage = "Error calling server $::NameServer";
      return 1;
}

I assume that these commands are used in a Unix environment and not a Windows environment.
gppkuntzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
System::Execute is not a CPAN module, so it's probably been written by the author of the script.  Without seeing the contents of System::Execute, it's impossible to say exactly what it does.

0
Adam314Commented:
Going along with Tintin, is there a "use System" anywhere (likely near the top) of the script?
If so, post the code for the System.pm file.
0
ozoCommented:
Did you load a module like
use System;
System::Execute($cmd) would call the Execute sub in the System module
you would need to consult documentation for that module to find what it does
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

gppkuntzAuthor Commented:
I missed the fact that one was a lower case "s" and the other upper case, system($cmd).
The System.pm is pasted below:
package System;
use File::Basename;
BEGIN {
        $::InstallDir = dirname("$0");
        push @INC, "$::InstallDir";

        select(STDERR);
        $| = 1;
        select(STDOUT);
        $| = 1;
        if ($ENV{'ProgRoot'} eq "")
            {$ENV{'ProgRoot'} = "$::InstallDir/..";
             print "Using default ProgRoot=$ENV{'ProgRoot'}\n";}
        push @INC, "$ENV{'ProgRoot'}/engine";
}

use Environment;
use Keyword;

BEGIN { }

#---------------------------------------------------------------------------------
# function: System
# description: Performs a specified system command
# parameters: ShellCommand OutputLog ErrorLog ContinueFlag
#---------------------------------------------------------------------------------
sub Execute {

      my ( $Command, $OutputLog, $ErrorLog, $ContinueFlag, $IsSilent ) = @_;
      my ( $Keyword, $IsPrintCommand );

      $IsPrintCommand = "yes";

      #---------------------------------------------------
      # check to see if secure keyword in command
      #---------------------------------------------------

      foreach $Keyword ($::KeywordsSecure) {
            if ( rindex( "$Command", "##" . $Keyword . "##" ) != -1 ) {

                  #---------------------------------------------------
                  # secure keyword exit, do not print value in log
                  #---------------------------------------------------
                  $IsPrintCommand = "no";
            }
      }

      #---------------------------------------------------
      # if keyword exists, print preprocessed command
      #---------------------------------------------------

      if ( "$IsPrintCommand" eq "yes" ) {
            if ( rindex( "$Command", "##" ) != -1 ) {
                  debugPrint("Executing $Command...\n") unless ($IsSilent);
            }
      }
      debugPrint("Executing $Command...\n") ;

      #---------------------------------------------------
      # if keywords exist, expand command keywords
      #---------------------------------------------------

      $Command = Keyword::Expand("$Command");

      #---------------------------------------------------
      # if specified, redirect output and error
      #---------------------------------------------------

      if ( "$OutputLog" ne "" ) {
            $Command = "$Command >$OutputLog";
      }

      if ( "$ErrorLog" ne "" ) {
            $Command = "$Command 2>$ErrorLog";
      }
      if ( system("$Command") ) {
            #---------------------------------------------------
            # shell command failed
            #---------------------------------------------------

            if ( "$IsPrintCommand" eq "yes" ) {
                  $::ErrorMessage = "Command failed for $Command";
                  infoPrint("Command failed for $Command \n") unless ($IsSilent);
            }
            else {
                  $::ErrorMessage = "Command failed";
                  infoPrint("Command failed \n") unless ($IsSilent);
            }

            if ( "$ContinueFlag" ne "yes" ) { return 0 }

            infoPrint("\nError: $::ErrorMessage") unless ($IsSilent);
            infoPrint("\nError: Continue On error set and processing continued\n\n")
              unless ($IsSilent);
                 return 0;  #when it fails
      }

      return 1;
}

sub infoPrint {
      print( $_[0] ."\n\n" );
      return 1;
}

sub debugPrint {
      if ( lc($::DEBUG_MODE) eq "yes" ) {
            print( $_[0] );
      }
      return 1;
}

sub rmdir {
      my ($dir) = $_[0];
      if ( lc($::DEBUG_MODE) eq "yes" ) {
            print("Attempting to clean up directory: $dir\n");
      }

      # do minimum security check, we do not want to rm -rf the whose root!
      if ( $dir =~ /^ *\/ *$/ ) {
            print("Can not clean root dir in this unix host!\n");
            return 0;
      }
      else {
            print("Cleaning up $dir:\n");
            system("rm -rf $dir");
      }
      return 1;
}

END { }

return 1;
0
Adam314Commented:
First, the rmdir function has the comment "do minimum security check, we do not want to rm -fr the whose root".
A malicious user could easily get around the regex using "/tmp/.." - allowing the root to be deleted.  Or the $dir passed could contain some_dir;some_other_command, would would allow the user of this function to run whatever command they wanted.

The System::Execute function you have runs the built-in system command, with a different options:
    The command is replaced using the Keyword::Command function.  Don't know what this function does.
        (look in the Keyword.pm file to see)
    The second parameter, if supplied, is where the commands STDOUT will be redirected
    The third parameter, if supplied, is where the commands STDERR will be redirected
    It looks to see if the command is "secure", supposedly to not print the command in a log
        But the debugPrint will print it anyways (later on it isn't printed though)
    If the system command returned a TRUE value, 0 is returned
    If the system command returned a FALSE value, 1 is returned
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gppkuntzAuthor Commented:
Thanks, I appreciate your time.  The keyword.pm appears not to have been completed before the originator left.  I was hoping that the built-in-system commands were implemented with just some options.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.