1. General information
2. proxycygterm.exe
3. proxywinconsole.exe
4. Other uses for the wrappers proxycygterm.exe and proxywinconsole.exe
Proxy32 built-in terminal can connect its user to different local or remote shells. There are three connection modes:
TELNET-TERMINAL and COM-PORT-TERMINAL are straightforward and will not be discussed here.
When using IPC to connect to local Windows shell, Proxy32 SHELL-TERMINAL starts local "shell" process via supplied command line and then communicates with the "shell" process using STDIN/STDOUT/STDERR streams in byte-oriented UTF-8/ASCII mode.
While such STDIN/STDOUT/STDERR interface in SHELL-TERMINAL allows to connect terminal window directly to cmd, plink and psftp, it does not allow to connect directly to CYGWIN shells (CYGWIN bash/ssh/sftp/telnet/ftp/screen/mc) that require allocation of CYGWIN TTY to be executed. It also does not allow to connect directly to Windows PowerShell (and to some other windows command line tools), as PowerShell requires allocation of Windows Console window for its execution.
For creation of SHELL-TERMINAL launcher user has to supply command line to start local interactive text mode process which new terminal will be running. For example:
plink.exe -ssh -P 22 -l sshuser -pw <PROXYPASSWORD=my ssh password> 192.168.1.9
will start local plink (putty's command line friend) ssh client and connect it to host 192.168.1.9 on the port 22 with user name "sshuser" and password stored in proxy32 protected parameter named "my ssh password".psftp.exe -P 22 -l sftpuser -pw <PROXYPASSWORD=my sftp password> 192.168.1.9
will start local psftp (putty's command line friend) sftp client and connect it to host 192.168.1.9 on the port 22 with user name "sftpuser" and password stored in proxy32 protected parameter named "my sftp password".cmd
will start local windows shell.To be able to connect to CYGWIN shells (CYGWIN bash/ssh/sftp/telnet/ftp/screen/mc), Proxy32 SHELL-TERMINAL uses intermediate process (or wrapper) called proxycygterm.exe. proxycygterm.exe creates CYGWIN TTY and starts CYGWIN shell on it, then it communicates (on PTY side) with Proxy32 SHELL-TERMINAL using STDIN/STDOUT/STDERR streams in byte-oriented UTF-8/ASCII mode.
I have derived "proxycygterm" code from "cygterm" code in March 2006 to use it as new Proxy32 to CYGWIN TTY interface. Source code of "proxycygterm" is published here (as "cygterm" code is licensed under GPL). GPL source code of unmodified CYGWIN binaries that Proxy32.exe installs is located here.
On resize of Proxy32 terminal it sends Telnet NAWS command to STDIN of proxycygterm.exe to resize slave TTY to match new size of the Proxty32 terminal. If SHELL-TERMINAL command line does not contain word "proxycygterm" then NAWS command is not sent to STDIN of SHELL-TERMINAL shell process. If shell process exited or died, Proxy32 terminal disconnects. If user "disconnects" Proxy32 terminal manually, shell process and all process tree it has created is killed.
For creation of SHELL-TERMINAL launcher user has to supply command line to start local interactive text mode process which new terminal will be running. For example:
command line proxycygterm.exe -s '/usr/bin/bash -i -l'
will start local CYGWIN bash shell on the CYGWIN TTY created by interface program "proxycygterm.exe".
command line proxycygterm.exe -s '/usr/bin/ssh -o StrictHostKeyChecking=no -o Port=22 -o User=sshuser 192.168.1.9'
will start local CYGWIN OpenSSH ssh client on the CYGWIN TTY created by interface program "proxycygterm.exe" and connect this ssh client to host 192.168.1.9 on the port 22 with user name "sshuser".
command line proxycygterm.exe -s '/usr/bin/sftp -o StrictHostKeyChecking=no -o Port=22 -o User=sftpuser 192.168.1.9'
will start local CYGWIN OpenSSH sftp client on the CYGWIN TTY created by interface program "proxycygterm.exe" and connect this sftp client to host 192.168.1.9 on the port 22 with user name "sftpuser".
command line proxycygterm.exe -s '/usr/bin/ftp 192.168.1.9 21'
will start local CYGWIN ftp client on the CYGWIN TTY created by interface program "proxycygterm.exe" and connect this ftp client to host 192.168.1.9 on the port 21.
command line proxycygterm.exe -s '/usr/bin/telnet 192.168.1.9 23'
will start local CYGWIN telnet client on the CYGWIN TTY created by interface program "proxycygterm.exe" and connect this telnet client to host 192.168.1.9 on the port 23.
command line proxycygterm.exe -s '/usr/bin/screen -s bash'
will start local CYGWIN "screen" application (for multiplexing multiple virtual vt100 terminals into one physical terminal) on the CYGWIN TTY created by interface program proxycygterm.exe
. Use ^aS
then ^aTAB
then ^ac
to split window, switch to newly created split, create second virtual vt100 terminal and start new shell in the second virtual terminal. Then you can use both virtual terminals and switch keyboard input between them with ^aTAB
(means press Ctrl-a first, then press TAB
). Further use of ^aS
then ^aTAB
then ^ac
will create more virtual terminals. This mode is convenient to control multiple connections from single terminal window under control of single script. Such operation allows to simulate functionality of cluster
(or vector
) terminal when multiple connections (for example, to several network nodes working in redundant load sharing cluster) are established in one shot and under control of single script. Issuing command ^a:caption always "%w"
will force status line under the screen of every virtual terminal.
command line proxycygterm.exe -s '/usr/bin/mc'
will start local CYGWIN Midnight Commander
application (similar to Norton Commander for DOS) on the CYGWIN TTY created by interface program "proxycygterm.exe".
I have written and included into Proxy32 installation new console wrapper that is similar to proxycygterm.exe (but closed source). As proxycygterm.exe creates CYGWIN TTY internally and wraps it into STDIN/STDOUT/STDERR external interface, the same way new wrapper proxywinconsole.exe
creates hidden MS Windows console and wraps it into STDIN/STDOUT/STDERR external interface (UTF-8 byte streams). It also has Ctrl-C handler on STDIN. Hidden console window has fixed 80 columns width, but when run in the SHELL-TERMINAL it has no limit on the number of lines in the scroll back buffer. proxywinconsole.exe can be used the same way as proxycygterm.exe, but for windows command line applications (that cannot run without native MS Windows console window attached
).
For creation of SHELL-TERMINAL launcher user has to supply command line to start local interactive text mode process which new terminal will be running. For example:
command line proxywinconsole.exe
will start MS Windows powershell on hidden windows console.
command line proxywinconsole.exe cmd
will start cmd
on hidden windows console, so some other programs called from cmd prompt will start working.
command line proxywinconsole.exe powershell
will start MS Windows powershell on hidden windows console.
Wrapper has handler to pass Ctrl-C (ASCII 03) from its STDIN to wrapped child process (cmd or powershell), so Ctrl-C can be used to interrupt long powershell and cmd printouts.
Wrapper also supports UTF8 on STDIN/STDOUT streams to use Unicode for non-English languages support.
Wrapper does not support console color attributes.
This wrapper is intended to attract MS Windows sysadmins
who use MS Windows powershell, cmd, net, reg and other MS Windows command line tools.
Current Limitations of the proxywinconsole.exe wrapper:
Wrapper only creates hidden console that is 80 column in width, so SHELL-TERMINAL automatically detects if it is running proxywinconsole.exe and adjusts terminal size to fixed 80x24 size.
Wrapper is not using internal screen buffer of the hidden console directly (as this buffer is only 9999 lines max) but instead extracts new characters that appear at the end of the internal screen buffer of hidden console window. Because of this design wrapper's output does not display "full screen" console applications correctly and it also does not display correctly when user tries to edit command line before execution (backspace, line up, line down, sending output via pager etc). This is the price to pay for having cmd and powershell output in the terminal with unlimited scrollback buffer and with search and bookmarking capabilities. When user does not use backspace, line up and line down and "output through the pager" everything is working fine for powershell, cmd and other tools that do not move the cursor directly, but only move it forward with the sequential text output.
For international users: Wrapper expects ASCII or Unicode UTF8 streams (STDIN/STDOUT) externally. Internally, UTF8 is converted to UTF16 for working with hidden console (MS Windows console does not support surrogate pairs aka Unicode Supplemental Plane, so 4-bytes long utf-8 codes are ignored).
For international users: On Windows XP, to enable Unicode output from the wrapper, after every reboot user has to open normal MS Windows console and set its font to Lucida Console
. This will pre-load Unicode font into some system console font table and then my wrapper will be able to use it on hidden console to produce Unicode output. Starting from Windows Vista, wrapper is loading Unicode font "Lucida Console" into hidden console automatically and no action is required from user to ensure Unicode support in the output of the wrapper.
Wrapper does not support console color attributes (yet?). Nobody asked for this. I can potentially translate console char color attributes into XTERM ESC sequences (SGR sequences) to switch color on the screen of the terminal that is receiving STDOUT of the wrapper.
Another obvious benefit of proxywinconsole.exe wrapper is its ability to run cmd or powershell from CYGWIN bash command line and from bash scripts
.
Also, before it was impossible to connect to powershell or cmd via CYGWIN OpenSSH ssh server
. Now it is working. First, one need to connect to CYGWIN OpenSSH sshd server on PC. This will provide bash prompt. Then simply start my wrapper from the bash prompt to start working with cmd/powershell via CYGWIN OpenSSH sshd server on PC.
Google search for "access powershell via CYGWIN OpenSSH server" returns a lot of people's frustration because of inability to run powershell via CYGWIN OpenSSH sshd server on PC.
powershell and CYGWIN OpenSSH sshd server on PC, link 1
powershell and CYGWIN OpenSSH sshd server on PC, link 2
powershell and CYGWIN OpenSSH sshd server on PC, link 3
powershell and CYGWIN OpenSSH sshd server on PC, link 4
powershell and CYGWIN OpenSSH sshd server on PC, link 5
There is even full blown commercial SSH server just to give folks access to powershell remotely!
Commercial POWERSHELL SSH SERVER
Also, this MinTTY development thread discusses problem that can be partially solved by using proxywinconsole.exe.
1. General information
2. proxycygterm.exe
3. proxywinconsole.exe
4. Other uses for the wrappers proxycygterm.exe and proxywinconsole.exe