Reputation: 2951
I'm trying to implement a perl script in Cygwin. The script makes a few different calls within. For example,
system "C:\\users\\program.exe";
or
exec("C:\\users\\program.exe");
When I try to run it in cygwin, it gives me the error:
sh: C:cygwin64cygdriveprogram.exe: command not found
I know this is a dumb question, but how do I make it find program.exe?? If I look through the directory in the cygwin terminal then program.exe is clearly there...
Once I have it find the program, I would like to spawn the new process in a new cygwin terminal.
Upvotes: 2
Views: 2414
Reputation: 139461
TMTOWTDI:
#! /usr/bin/env perl
use strict;
use warnings;
my @cmd = ("/c", "echo", "hi" );
system('C:\\Windows\\System32\\cmd.exe', @cmd) == 0 or die;
system('C:/Windows/System32/cmd.exe', @cmd) == 0 or die;
system('/cygdrive/c/Windows/System32/cmd.exe', @cmd) == 0 or die;
chomp(my $cmd = `cygpath 'C:\\Windows\\System32\\cmd.exe'`);
system($cmd, @cmd) == 0 or die;
Upvotes: 2
Reputation: 7949
Use Unix file separators and the /cygdrive/c/
virtual drive:
system "/cygdrive/c/users/program.exe";
or
exec("/cygdrive/c/users/program.exe")
Upvotes: 4
Reputation: 385789
exec("C:\\users\\program.exe");
executes the bourne shell command
C:\users\program.exe
which is a weird way of writing
C:usersprogram.exe
Executing the following shell command might work:
C:\\users\\program.exe # exec("C:\\\\users\\\\program.exe");
But the correct path is
/cygdrive/c/users/program.exe # exec("/cygdrive/c/users/program.exe")
Upvotes: 2