emacs shell-mode window 中 prlctl exec 的问题

Problems with prlctl exec inside emacs shell-mode window

问:谁能告诉我如何在 emacs shell 模式缓冲区中 运行 "prlctl exec"?

---+ emacs shell 模式中的 prlctl 问题

我有一个 Windows 虚拟 machine 运行ning 在 Mac.

上的 Parallels 之上

我想在 Mac 的 OS-X 上写一些 shell 和 运行 的 Perl 脚本 类 UNIX 环境,在 Parallels 上调用 Windows 应用程序。 特别是 FrameMaker。

具体来说,我希望能够在 macs,运行ning native 上工作 Mac,然后执行 esc-x 编译为 运行 一个 Makefile - 说 Makefile 执行 运行ning FrameMaker ExtendScript 命令之类的操作, 做一些事情,比如更新一本书的内容 table FrameMaker,将 FrameMaker 文件保存为文本或 PDF 等。基本上, 遗憾的是,常见的自动化类型已不再常见。

去年我在 Windows 上使用 Cygwin 完成了所有工作,但我 切换到使用 Mac with Parallels.

prlctl 命令似乎是我需要运行 的一个命令。 具体来说,"prlctl exec",或者 possibly "prlctl enter" for console 类型用法。

问题:prlctl exec 在 emacs 下的 shell 模式缓冲区中 运行 效果不佳 在 Mac.

prlctl exec 在 MacOS 终端 window.

中似乎 运行 没问题

但是在 emacs shell 模式缓冲区中,嗯:

a) 运行 "prlctl enter" 在 emacs shell 模式缓冲区中工作。 我可以 运行 DOS 命令行类型的命令。但是当我退出 "prlctl enter" 会话,它总是退出 shell 控制 shell 模式缓冲区。

b) 类似地,像 "prlctl exec ..." 运行 这样的命令在 emacs shell-模式缓冲区,但是当执行的命令终止时,它 终止控制 shell 模式缓冲区的 shell。

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

我推测 "prlctl" 正在远程控制 Windows 命令 通过某种伪终端拦截。而且它已经 使用交互式 MacOS 终端 window 进行测试,但它不起作用 使用用于 emacs shell-mode.

的伪终端

问:有没有人设法使类似的东西起作用?

说“只需 运行 来自 Mac 终端的 prlctl exec 命令 window 可能 almos不是正确的做法,尽管作为 emacs 本地人, 那会很痛苦。但即使 运行ning 来自 Mac 终端 window, 我遇到 prtlctl 的问题可能与此类似。

到目前为止,我还无法通过 prlctl 启动 FrameMaker, 尽管我可以通过 .BAT 文件或 PowerShell 轻松启动它。

---+ emacs shell buffers

的 prlctl 问题示例

---++ prlctl 在mac终端成功进入运行ning window

   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 shell-mode buffer

中输入 运行ning
$ bash glew@Andy-Glew-MacBook-Pro [~/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 glew@Andy-Glew-MacBook-Pro [~/hack]  c48  h1223 j0 $
$ bash  ~/hack $>
$ bash 1223 $>  exit

Process shell finished

我在上面输入的 "exit" 导致 prlctl enter 退出,因为它应该 - 但它显然也被发送到 emacs shell-mode 控制进程.

---++ prlctl exec 在macos终端window

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 execs

---++ prlctl exec in an emacs shell-mode buffer

$ 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 glew@Andy-Glew-MacBook-Pro [~/hack]  c45  h1227 j0 $
$ bash  ~/hack $>
$ bash 1227 $>  exit

Process shell finished

同样,似乎正在向 "exit" 命令提供 Windows prlctl exec 的命令解释器 - 看起来像 prlctl exec 建立在 prlctl enter 之上 - 并且被提供给 Windows命令解释器和emacs shell-模式控制 过程。

---++ 在 Mac 终端中后台运行 prlctl exec 命令 window

首先,没有背景:

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

它挂了一会儿。看来,即使在 MacOS 终端 window,prlctl 需要某种控制 tty 访问 exec - 尽管它不应该用于此命令。

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 shell-mode buffer

中后台运行 prlctl exec 命令

会话文本已缩进。

我会注释

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

$ bash glew@Andy-Glew-MacBook-Pro [~/hack]  c44  h1226 j0 $
$ bash  ~/hack $>
$ bash 1226 $>  prlctl exec WinVM echo hi &
[1] 63659
✓ 02:39:20 PM Saturday 2015-10-17

这里停顿了一下,终于下面的僵硬出现了—— 看起来 prlctl 正在将 "exit" 发送回 shell 模式。

$ bash glew@Andy-Glew-MacBook-Pro [~/hack]  c45  h1227 j1 $
$ bash  ~/hack $>
$ bash 1227 $>  exit

Process shell finished

使用更长的命令,例如 "prlctl exec ... ipconfig",会出现更多内容:

$ bash glew@Andy-Glew-MacBook-Pro [~/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 glew@Andy-Glew-MacBook-Pro [~/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

OK,这里停了一会儿。然后它看起来像 prlctl exec 开始向 emacs shell-模式控制进程发送废话:

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

就像他们向 shell 发送的文本没有得到回显(可能是 f emacs 配置的结果),并导致各种问题:

[2]+  Stopped                 prlctl exec WinVM ipconfig | grep localdomain
✗ 02:36:10 PM Saturday 2015-10-17
$ bash glew@Andy-Glew-MacBook-Pro [~/hack]  c49  h1234 j2 $
$ bash  ~/hack $>
$ bash 1234 $>  bash: syntax error near unexpected token `.*'
✗ 02:36:10 PM Saturday 2015-10-17
$ bash glew@Andy-Glew-MacBook-Pro [~/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\^KE2n6^C0^C2^E375^D^W6^D560^D5^P^[^?6^C4g000O5UE7p: event not found
✗ 02:36:10 PM Saturday 2015-10-17
[3] 58511
[3]   Exit 127                Q0^C60731wk4
✗ 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

实际上,我不想os显示上一行,因为它暗示了一个 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

平行版本

$ 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 glew@Andy-Glew-MacBook-Pro [~/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

为了 运行 在后台运行 Parallels exec,我找到了 2 种不同的方法:

将 null 发送到 STDIN,您的命令应该不会提供任何输出。看例子:

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

使用 xargs 在不同的 shell 中执行每个 prlctl 命令,您可以在其中定义同时处理的最大数量:

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

查看此工作示例(适用于 Linux 和 Mac):

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

希望对您有所帮助