2015-10-17 113 views
0

问:谁能告诉我如何在emacs shell模式缓冲区中运行“prlctl exec”?在Emacsemacs shell模式窗口中prlctl exec的问题

--- + prlctl问题shell模式

我有一个Mac上的Parallels上运行的Windows虚拟机。

我想编写一些在Mac OS-X 类UNIX环境中运行的shell脚本和Perl脚本,它可以在Parallels上调用Windows应用程序。 具体FrameMaker。

具体来说,我希望能够在emacs中工作,在 在Mac上运行本地,然后做ESC-X编译运行的Makefile - 说 的Makefile做事喜欢跑步FrameMaker的ExtendScript命令, 做的事情例如更新 FrameMaker中的书籍目录,将FrameMaker文件保存为文本或PDF等。基本上, 不幸的是,不幸的是,这种自动操作常常不那么常见。

去年我在Windows上使用Cygwin的所有工作,但我使用带有Parallels的Mac切换到 。

prlctl命令似乎是我需要运行一个命令。 具体而言,“prlctl exec”或可能“prlctl enter”用于控制台 类型的用法。

问题:prlctl exec在Mac上的emacs 下的shell模式缓冲区中运行不正常。

prlctl exec似乎在MacOS终端窗口中运行正常。

但在emacs shell模式缓冲区,以及:

一)运行“prlctl进入”工作的一个Emacs壳模式缓冲区工作。 我可以运行DOS命令行类型的命令。但是当我退出 “prlctl enter”会话时,它总是退出控制shell模式缓冲区的shell。 b)类似地,像“prlctl exec ...”这样的命令在emacs shell模式缓冲区中运行,但当exec'ed命令终止时,它会终止控制shell模式缓冲区的shell。

c)如果我尝试将prlctl exec放在后台,例如(prlctl exec ... &), 事情变得疯狂。看起来像是键盘控制代码的东西会被发送到控制emacs shell模式缓冲区的shell的 。

我猜想“prlctl”是通过某种伪终端拦截来远程控制Windows命令 。并且已经通过交互式MacOS终端窗口对 进行了测试,但它不起作用 与用于emacs外壳模式的伪终端。

问:有没有人设法做出这样的工作?

说“刚刚从Mac终端窗口 可能遇到的prlctl exec命令几乎是做正确的事,但作为一个emacs的人, 这将是痛苦的。但即使从Mac终端窗口中运行时, 我得到prtlctl的问题,可能是类似的。

到目前为止,我还没有能够在所有通过prlctl启动FrameMaker的了, 虽然我可以很容易地通过一个.bat文件或通过PowerShell中启动它。

--- + prl的示例CTL问题的emacs壳缓冲器

--- ++ prlctl输入一个MAC终端窗口

Andy-Glew-MacBook-Pro:~ glew$ prlctl list 
    UUID         STATUS  IP_ADDR   NAME 
    {3b5c5ff5-2909-4a8b-a9e6-a54d909ba98c} running  -    WinVM 
    Andy-Glew-MacBook-Pro:~ glew$ prlctl enter WinVM 
    Microsoft Windows [Version 6.3.9600] 
    (c) 2013 Microsoft Corporation. All rights reserved. 

    C:\>echo hi 
    echo hi 
    hi 

    C:\>exit 
    exit 
    Andy-Glew-MacBook-Pro:~ glew$ 
    Andy-Glew-MacBook-Pro:~ glew$ 

--- ++ prlctl成功运行在emacs的壳模式缓冲区输入运行

$ bash [email protected] [~/hack] c47 h1222 j0 $ 
$ bash ~/hack $> 
$ bash 1222 $> prlctl enter WinVM 
Microsoft Windows [Version 6.3.9600] 
(c) 2013 Microsoft Corporation. All rights reserved. 

C:\>echo hi 
echo hi 
hi 

C:\>exit 
exit 
✓ 02:27:14 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c48 h1223 j0 $ 
$ bash ~/hack $> 
$ bash 1223 $> exit 

Process shell finished 

“退出”我输入上面造成prlctl进入,退出,因为它应该 - 但它显然也得到了发送到emacs的壳模CONTROLLI ng进程。

--- ++在MacOS的终端窗口

Andy-Glew-MacBook-Pro:~ glew$ prlctl exec WinVM ipconfig | grep localdomain 
    Connection-specific DNS Suffix . : localdomain 
Tunnel adapter isatap.localdomain: 
    Connection-specific DNS Suffix . : localdomain 
Andy-Glew-MacBook-Pro:~ glew$ 

这工作,我可以输入多个命令prlctl EXEC键。我还可以在脚本

--- ++在emacs的壳模式缓冲区

$ bash 1226 $> prlctl exec WinVM ipconfig | grep local 
    Connection-specific DNS Suffix . : localdomain 
    Link-local IPv6 Address . . . . . : fe80::958c:20a3:da02:2903%3 
Tunnel adapter isatap.localdomain: 
    Connection-specific DNS Suffix . : localdomain 
    Link-local IPv6 Address . . . . . : fe80::249d:2248:f52c:c8fc%5 
✓ 02:31:43 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c45 h1227 j0 $ 
$ bash ~/hack $> 
$ bash 1227 $> exit 

Process shell finished 

再次prlctl EXEC,它看起来像一个“退出”执行多个prlctl高层命令被供应到 由prlctl exec执行的Windows命令解释程序 - 它看起来像是prlctl exec 构建在prlctl enter之上 - 并提供给 Windows命令解释程序和emacs shell模式控制 进程。

--- ++在MAC终端窗口

首先,unbackgrounded Backgrounding一个prlctl exec命令:

Andy-Glew-MacBook-Pro:~ glew$ prlctl exec WinVM ipconfig | grep localdomain 
    Connection-specific DNS Suffix . : localdomain 
Tunnel adapter isatap.localdomain: 
    Connection-specific DNS Suffix . : localdomain 

然后,转到后台:

Andy-Glew-MacBook-Pro:~ glew$ prlctl exec WinVM ipconfig | grep localdomain & 
[1] 63866 
Andy-Glew-MacBook-Pro:~ glew$ 

[1]+ Stopped     prlctl exec WinVM ipconfig | grep localdomain 

它挂HRE一段时间。看来,即使在MacOS终端 窗口中,prlctl exec也需要某种形式的tty访问控制 - 尽管它不应该用于此命令。

Andy-Glew-MacBook-Pro:~ glew$ fg 
prlctl exec WinVM ipconfig | grep localdomain 

^C^C 
^D 
^ZAndy-Glew-MacBook-Pro:~ glew$ 
Andy-Glew-MacBook-Pro:~ glew$ 
Andy-Glew-MacBook-Pro:~ glew$ 

--- ++在emacs的壳模式缓冲区

会话缩进文字Backgrounding一个prlctl exec命令。

我会标注

首先,最短prlctl exec命令我知道:

$ bash [email protected] [~/hack] c44 h1226 j0 $ 
$ bash ~/hack $> 
$ bash 1226 $> prlctl exec WinVM echo hi & 
[1] 63659 
✓ 02:39:20 PM Saturday 2015-10-17 

它暂停这里一段时间,但低于最终僵硬出现 - 它看起来像prlctl正在发送“退出”回到shell模式。

$ bash [email protected] [~/hack] c45 h1227 j1 $ 
$ bash ~/hack $> 
$ bash 1227 $> exit 

Process shell finished 

有了较长的命令,如 “prlctl EXEC ... IPCONFIG”,出现更多的东西:

$ bash [email protected] [~/hack] c44 h1227 j0 $ 
$ bash ~/hack $> 
$ bash 1227 $> prlctl exec WinVM ipconfig | grep localdomain & 
[1] 58231 
✓ 02:36:10 PM Saturday 2015-10-17 

以上是我进入prlctl exec命令。

$ bash [email protected] [~/hack] c45 h1228 j1 $ 
$ bash ~/hack $> 
$ bash 1228 $> exit 
There are stopped jobs. 

[1]+ Stopped     prlctl exec WinVM ipconfig | grep localdomain 
✓ 02:36:10 PM Saturday 2015-10-17 

好吧,它暂停了一会儿。然后,它看起来像prlctl EXEC 开始发送垃圾到Emacs的外壳模式控制过程:

$ bash [email protected] [~/hack] c45 h1229 j1 $ 
$ bash ~/hack $> 
$ bash 1229 $> [2] 58298 
✓ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c46 h1230 j2 $ 
$ bash ~/hack $> 
$ bash 1230 $> bash: his:: command not found 
✗ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c47 h1231 j2 $ 
$ bash ~/hack $> 
$ bash 1231 $> bash: s: command not found 
✗ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c48 h1232 j2 $ 
$ bash ~/hack $> 
$ bash 1232 $> ✗ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c48 h1233 j2 $ 
$ bash ~/hack $> 
$ bash 1233 $> bash: e: command not found 

这就像他们发送文本未得到回应的外壳(可能是一个结果f emacs的配置) ,并引起各种打嗝:

[2]+ Stopped     prlctl exec WinVM ipconfig | grep localdomain 
✗ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c49 h1234 j2 $ 
$ bash ~/hack $> 
$ bash 1234 $> bash: syntax error near unexpected token `.*' 
✗ 02:36:10 PM Saturday 2015-10-17 
$ bash [email protected] [~/hack] c49 h1235 j2 $ 
$ bash ~/hack $> 
$ bash 1235 $> > > > ✗ 02:36:10 PM Saturday 2015-10-17 
bash: syntax error near unexpected token `1' 
    > > > ✗ 02:36:10 PM Saturday 2015-10-17 
bash: syntax error near unexpected token `1' 

现在,我得到了很多这方面的东西... ...剪断

bash: syntax error near unexpected token `1' 
✗ 02:36:10 PM Saturday 2015-10-17 
> > > > > > > > > > > > > > > > > > bash: syntax error near unexpected token `)' 
✗ 02:36:10 PM Saturday 2015-10-17 
bash: !s\21\^KE\332n\216^C\340^C\262^E\223\377\315^D^W\236^D\375\236\270^D\325^P^[^?\376^C\234g000O\205UE\257p: event not found 
✗ 02:36:10 PM Saturday 2015-10-17 
[3] 58511 
[3] Exit 127    Q\320^C\3660\307\203\351wk\244 
✗ 02:36:10 PM Saturday 2015-10-17 

...很多更多的相同 - 看起来像控制代码

✗ 02:36:10 PM Saturday 2015-10-17 
bash: syntax error near unexpected token `)' 
✗ 02:36:10 PM Saturday 2015-10-17 
bash: syntax error near unexpected token `&' 

Process shell bus error: 10 

其实,我几乎不犹豫地显示上一行,因为它表明了一个shell错误。

--- +配置信息

的MacBook Pro中旬2014

$ bash 1229 $> uname -a 
Darwin Andy-Glew-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 

的Parallels版本

$ bash 1230 $> prlctl --version 
prlctl version 10.3.0 (29227) rev 0 


From the Parallels Desktop about: 
Version 10.3.0 (29227) 
(same as for the command line) 

Windows版本

Manually editing systeminfo to keep only the good bits 

$ bash 1232 $> prlctl exec WinVM systeminfo 

OS Name:     Microsoft Windows 8.1 Pro 
OS Version:    6.3.9600 N/A Build 9600 
OS Manufacturer:   Microsoft Corporation 
OS Configuration:   Standalone Workstation 
OS Build Type:    Multiprocessor Free 

System Boot Time:   10/17/15, 1:56:38 PM 
System Manufacturer:  Parallels Software International Inc. 
System Model:    Parallels Virtual Platform 
System Type:    x64-based PC 
Processor(s):    1 Processor(s) Installed. 
       [01]: Intel64 Family 6 Model 70 Stepping 1 GenuineIntel ~2793 Mhz 
BIOS Version:    Parallels Software International Inc. 10.3.0 (29227) rev 0, 9/21/15 

Total Physical Memory:  12,272 MB 
Available Physical Memory: 8,753 MB 
Virtual Memory: Max Size: 14,128 MB 
Virtual Memory: Available: 10,808 MB 
Virtual Memory: In Use: 3,320 MB 
$ bash [email protected] [~/hack] c47 h1233 j0 $ 
$ bash ~/hack $> 
$ bash 1233 $> exit 

Process shell finished 

and, as usual, prlctl exec closes the emacs shell-mode buffer I ran in in 

(emacs的版本)

GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.16) of 2015-01-17 on Andys-MacBook-Pro.local 

回答

2

为了在后台运行在Parallels高管,我发现2种不同的这样做的方法:

发送空到STDIN和你的命令应不提供输出。见例如:

prlctl exec 'Windows XP' /temp/script.bat argument1>NUL </dev/null & 

使用xargs的,在这里你可以定义同时处理的最大数量在不同的外壳执行每个prlctl命令:

echo var1 var2 var3 | xargs -I{} -P 4 bash -c "prlctl exec 'Windows XP' /temp/script.bat argument1>NUL" 

见该工作示例(适用于Linux和苹果机):

seq 10 | xargs -I{} -P 4 bash -c "echo start {}; sleep 3; echo done {}" 

我希望这有助于

+0

谢谢。 I/O重定向帮助。但是(1)我仍然无法将参数传递给prlctl .bat脚本 - 既不是直接的,也不是当我尝试通过command.exe/c运行它们时,以及(2)我无法获得像记事本一样的GUI应用程序来打开。 //正如http://stackoverflow.com/questions/41456329/most-secure-way-to-run-guest-apps-from-host中所述,我已经切换到使用VirtualBox进行自动化 - 但我希望获得自动化在Parallels的工作中,因为Parallels比VirtualBox做了一些更好的事情。 –