无法使用绝对路径在cygwin下运行PhantomJS
我无法使用argument.js文件的绝对路径在cygwin下运行PhantomJS。以下是我设置PhantomJS的步骤:无法使用绝对路径在cygwin下运行PhantomJS,cygwin,phantomjs,Cygwin,Phantomjs,我无法使用argument.js文件的绝对路径在cygwin下运行PhantomJS。以下是我设置PhantomJS的步骤: 已下载适用于windows的PhantomJS 1.9.7 已将PhantomJS可执行文件复制到c:\cygwin64\bin\ 将解压后的PhantomJS下载文件中的文件“hello.js”复制到我的cygwin主目录中 已启动cygwin/xterm 如果我跑步: whichphantomjs 在我的cygwin xterm中,它正确地响应为: Hello, wo
whichphantomjs
在我的cygwin xterm中,它正确地响应为:
Hello, world!
/usr/bin/phantomjs
如果我从主目录运行以下命令:
phantomjs hello.js
PhantomJS正确响应为:
Hello, world!
另一方面,如果我运行以下命令:
phantomjs /home/user1/hello.js
/usr/bin/phantomjs /home/user1/hello.js
PhantomJS回复:
Can't open '/home/user1/hello.js'
如果我运行这个:
phantomjs /home/user1/hello.js
/usr/bin/phantomjs /home/user1/hello.js
幻影仍然回答:
Can't open '/home/user1/hello.js'
我尝试的每一条绝对路径都是这样。为什么PhantomJS不能处理绝对文件路径?我在示例中显示的路径没有任何空格、特殊字符等,因此我不确定问题出在哪里
我还尝试在windows下的命令提示符下运行相同的测试,有时它会显示相同的行为,但并不总是如此。我似乎再也不能在windows下重现这个错误了,所以我不知道还能说些什么
有人知道问题出在哪里吗?我找到了解决办法。通过cygwin运行本机windows程序需要将cygwin的POSIX路径转换为windows样式的路径。在我上面的例子中,以下工作:
phantomjs "`cygpath -w /cygdrive/c/cygwin64/home/user1/hello.js`"
返回:
Hello, world!
我还不确定回执是干什么用的,但至少我找到了解决办法。你试过
/cygdrive/c/home/user1/hello.js
?我试过/usr/bin/phantomjs/cygdrive/c/cygwin64/home/user1/hello.js
,它仍然说:不能打开“/cygdrive/c/cygwin64/home/user1/hello.js”
你应该回答这个问题。另外,请检查您的其他问题。我想你至少找到了一个可以接受的答案。