2

Below is the code of setup.pl:

my  $fileToCopy= "ewq_file.bat";
my $destination = $ENV{PREPARE};   ### $destination = C:\Windows
if ( -f "$destination\\$fileToCopy" ) {
    print "Triggering $destination\\$fileToCopy\n";
    system("start $destination\\$fileToCopy"); 
}

On triggering: C:\cygwin\bin\perl.exe setup.pl

Output:

Triggering C:\Windows\ewq_file.bat
sh: start: command not found

How can i resolve this issue?

0

1 Answer 1

5

You're using a unix build of Perl in a unix emulation environment. system thus uses sh unless you tell it otherwise. But start is a cmd builtin.

system( "cmd", "/c", "start", "", "$destination\\$fileToCopy" );

die( "Can't launch shell: $!\n"                   ) if $? == -1;
die( "Child killed by signal ".( $? & 0x7F )."\n" ) if $? & 0x7F;
die( "Child exited with error ".( $? >> 8 )."\n"  ) if $? >> 8;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.