在emacs shell模式窗口中prlctl exec的问题



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

——+ prlctl问题

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

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

具体来说,我希望能够在emacs中工作,在本机上运行Mac,然后做esc-x编译运行一个Makefile -说Makefile做一些事情,比如运行FrameMaker ExtendScript命令,做一些事情,比如更新一本书的目录将FrameMaker文件保存为文本或PDF等。基本上,常见的自动化类型,不幸的是,它们不再那么常见了。

去年我在Windows上使用Cygwin,但我没有切换到使用Mac和Parallels。

prlctl命令似乎是我需要运行的命令。具体来说,"prlctl exec"或"prlctl enter"表示控制台类型使用。

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

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

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

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

b)类似地,像"prlctl exec…"这样的命令在emacs中运行shell模式的缓冲区,但是当exec 'Ed命令终止时,它将返回终止控制shell模式缓冲区的shell。

c)如果我试图把prlctl执行在后台,例如(prlctl执行…,),事情变得疯狂。什么看起来像键盘控制代码被发送到Shell控制emacs Shell模式缓冲区

我猜想"prlctl"是远程控制Windows命令通过某种伪终端拦截。事实也的确如此在交互式MacOS终端窗口中进行了测试,但它不起作用使用emacs shell模式使用的伪终端。

问:有没有人做过这样的事情?

说"只要在Mac终端窗口运行prlctl exec命令可能几乎是正确的做法,尽管作为emacs本地用户,那会很痛苦的。但即使在Mac终端窗口中运行,我在使用prtlctl时会遇到类似的问题。

到目前为止,我还不能通过prlctl启动FrameMaker,虽然我可以很容易地通过。bat文件或PowerShell启动它。

——+ emacs shell缓冲区prlctl问题示例

——++ prlctl enter running successfully ina mac terminal 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 enter在emacs shell模式缓冲区中运行

$ 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模式控制进程。

——++ prlctl exec在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执行

——++ prlctl exec在emacs shell模式缓冲区

$ 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

再次,它看起来像一个"退出"命令被提供给Windows命令解释器由prlctl exec -它看起来像prlctl exec是建立在PRLCTL进入-并提供给两个Windows命令解释器和对emacs shell模式的控制过程。

——++在Mac终端窗口中执行prlctl exec命令

首先,unbackgrounded:

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终端上窗口中,PRLCTL需要某种类型的控制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 shell模式缓冲区中执行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正在发送一个"退出"回shell模式。

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

使用较长的命令,如"prlctl exec…">

$ 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

好的,它在这里暂停了一会儿。然后它看起来像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发送文本而没有得到回显(可能是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: !s21^KE332n216^C340^C262^E223377315^D^W236^D375236270^D325^P^[^?376^C234g000O205UE257p: event not found
✗ 02:36:10 PM Saturday 2015-10-17
[3] 58511
[3]   Exit 127                Q320^C3660307203351wk244
✗ 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错误。

—+ Config Info

MacBook Pro mid 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-version)
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,我发现了两种不同的方法:

发送null到STDIN和你的命令应该没有输出. 参见示例:

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

在不同的shell中使用xargs执行每个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 {}"

我希望这对你有帮助

最新更新