2015-10-17 39 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做了一些更好的事情。 –