(我知道这是一个基本的/新手的错误.但我怀疑我是第一个或最后一个犯这个错误的人……所以我会在这里记录下来,所以未来像我一样可以谷歌吧.)
这些脚本冻结,因为它们实际上是shell脚本.这些shell脚本实际上正在运行导入命令行程序…由ImageMagick包提供:
$sh freeze.hs
C-c
$which import
/usr/bin/import
$man import | head -10
... import - saves any visible window on an X server and outputs it as an image file.
$import screenshot.ps
... and here notice the mouse icon changes to a cross-hair icon ...
... so then press the mouse button to finish this operation ...
$file screenshot.ps
screenshot.ps: PostScript document text conforming DSC level 3.0, Level 1
因此,我向ImageMagick工作人员致敬,他提供了一个很好的,无声的命令行操作.
至少在各种基于Linux的操作系统上,这些脚本会触发导入命令行程序的操作. BSD,Windows,MacOS等可能会有不同的反应.
以下是使用Python解释器和ghc编译器的脚本的正确操作:
$python freeze.py
hello
$runghc freeze.hs
"hello"
或者,包括#! shebang:
$ls -l no_freeze.py
-rwx------ 1 rick rick 46 Oct 27 11:44 no_freeze.py
$cat no_freeze.py
#!/usr/bin/env python
import re
print "hello"
$./no_freeze.py
hello
Haskell也一样:
$ls -l no_freeze.hs
-rwx------ 1 rick rick 68 Oct 27 11:26 no_freeze.hs
$cat no_freeze.hs
#!/usr/bin/env runghc
import Text.Regex.Posix
main = print "hello"
$./no_freeze.hs
"hello"
在我的MacOS计算机上,我收到此错误,因为我的X11设置的某些部分尚未完成.对于那些没有安装X11的人,我想你会得到命令not found error.
$import screenshot
Version: ImageMagick 6.9.5-0 Q16 x86_64 2016-07-02 http://www.imagemagick.org
...
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.