Using msh.exe interactively from within other programs
Thursday, 20 April 2006
In a recent post, Andy describes his quest to use msh.exe as the Emacs interactive shell. He got single commands to work, but the interactive experience does not output any prompts. This will be the experience from any application that redirects Monad’s standard input stream.
First, the syntax to make Monad read commands from a redirected input stream is “-command –“. This places Monad into batch input mode. In the batch input mode, Monad treats standard input as though it is content in a script, allowing a scenario like:
type test.msh | msh -command – > output.txt
Batch input mode suppresses prompting so that the prompts do not interfere with the script’s output. You will see a similar problem if you try to use Monad directly as a Telnet / SSH endpoint
We are aware of this limitation, and hope to fix the issue in V2. As always, we invite you to provide your feedback on this decision at the Monad Microsoft Connect site.
[Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.]


Subscribe to this blog.
No. 1 — April 20th, 2006 at 9:29 pm
That did the trick – I can execute commands in Emacs now. It’s definitely a bit wierd not to see any prompts, but I’ll take what I can get. Thanks for the tip! :)
No. 2 — April 22nd, 2006 at 7:34 pm
Won’t this work? msh -command – < test.msh > output.txt
No. 3 — April 24th, 2006 at 12:09 am
It does work, Faried — I’m not sure what you’re responding to :)
The limitation I wrote about deals with an interactive redirected shell (ie: in Emacs, or as an SSH endpoint.)
Lee