更新时间:2023-11-19 20:03:16
尝试:
wgetexe =/ cygdrive / C / Program Files(x86)/GnuWin32/wget.exe
$ wgetexe--help
由于它是一个可执行文件,因此不希望将其作为参数传递给bash,这将尝试作为脚本执行。它在路径名中有空格,您需要引用该名称,以便shell不尝试使用无效参数执行 cygdrive / C / Program
。
您还应该能够将目录添加到 $ PATH
:
PATH =$ PATH:/ cygdrive / C / Program Files(x86)/ GnuWin32
请记住,GnuWin32程序是Windows可执行文件,它们使用的任何文件路径将使用Windows语法解释。 Cywin可执行文件(任何使用 cygwin1.dll
)使用Cygwin路径语法。
更好的是,安装Cygwin版本 wget
,只需调用 wget --help
。
例如,如果您使用GnuWin32 wget
,您可以使用:
wget -OC:\cygwin\home\yourname\output-file$ url
而使用Cygwin wget
,您可能使用:
wget -O/ home / yourname / output-file$ url
我始终发现最简单的方法是尽可能使用Cygwin可执行文件。
I am having trouble executing a program located in the "C:\Program Files (x86) directory in Windows from within Cygwin. Anyone know the trick to getting this to work?
jboss@QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help"
jboss@QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash $wgetexe
bash: /cygdrive/C/Program: No such file or directory
jboss@QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash "$wgetexe"
bash: /cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help: No such file or directory
Try this:
wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe"
"$wgetexe" --help
Since it's an executable, you don't want to pass it as an argument to bash, which will try to execute it as a script. Since it has spaces in the path name, you need to quote the name so the shell doesn't try to execute cygdrive/C/Program
with invalid arguments.
You should also be able to add the directory to your $PATH
:
PATH="$PATH:/cygdrive/C/Program Files (x86)/GnuWin32"
Keep in mind that GnuWin32 programs are Windows executables, and any file paths they use will be interpreted using Windows syntax. Cywin executables (anything that uses cygwin1.dll
) use Cygwin path syntax.
Better yet, install the Cygwin version of wget
and just invoke it as wget --help
.
For example, if you're using the GnuWin32 wget
, you might use:
wget -O "C:\cygwin\home\yourname\output-file" "$url"
whereas with the Cygwin wget
you might use:
wget -O "/home/yourname/output-file" "$url"
I've always found it easiest to use Cygwin executables from Cygwin whenever possible.