문제

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.

도움이 되었습니까?

해결책

Use Unix file separators and the /cygdrive/c/ virtual drive:

system "/cygdrive/c/users/program.exe"; 

or

exec("/cygdrive/c/users/program.exe")

다른 팁

 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")

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top