After you have installed Cygwin and Cygwin/X, view this demo to see some of the many things you can do with Cygwin/X. 1. Start a local "XServer" by clicking the "XServer Start" icon (a shortcut to startx.bat, the last line of which is the call to start up the XServer): @echo off SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB SET XNLSPATH=/usr/X11R6/lib/X11/locale if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0 del %CYGWIN_ROOT%\tmp\.X11-unix\X0 :CLEANUP-FINISH if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix if "%OS%" == "Windows_NT" goto OS_NT echo startxwin.bat - Starting on Windows 95/98/Me goto STARTUP :OS_NT echo startxwin.bat - Starting on Windows NT/2000/XP/2003 :STARTUP run XWin -multiwindow -clipboard -silent-dup-error 2. Double-clicking a shortcut to "Linux MyBox (fuu-220)" brings up a terminal to that particular machine. The shortcut command looks like this: "E:\My Documents\scripts\xterm.bat" fuu-220 itdb1 green The xterm.bat script looks like this: @echo off REM Script for using Cygwin's xterm and ssh to connect to Unix from Windows REM Written By David Brown, EDS doc.brown@eds.com 317.230.3623 REM ARGUMENTS %1 %2 %3 %4 %5 REM Setup Cygwin environment... SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB SET XNLSPATH=/usr/X11R6/lib/X11/locale REM Startup a remote xterm to %1 as user %2 using ssh (fgcolor %3 and bgcolor %4) REM Argument %5 is a flag that if set (to anything) will set ssh to use compression REM To forward X11 traffic through ssh connection you must add lines to ~/.ssh/config: REM Host * REM ForwardX11 yes REM You also need to create a key using ssh-keygen on the local machine and add it to REM the authorized_keys file on the remote host to bypass password prompts REM Setup the inital values for the arguments, and ask for host and user if missing... set host=%1 set user=%2 set fgcolor=%3 set bgcolor=%4 set comp=%5 set default=%USERNAME% :HOST if NOT [%host%]==[] goto USER :AGAIN set /p host=Please enter host: if [%host%]==[] goto AGAIN :USER if NOT [%user%]==[] goto FGCOLOR set /p user=Please enter user [%default%]: if [%user%]==[] set user=%default% :FGCOLOR if NOT [%fgcolor%]==[] goto BGCOLOR set fgcolor=white :BGCOLOR if NOT [%bgcolor%]==[] goto COMP set bgcolor=black :COMP if [%comp%]==[] goto CONNECT set comp=-C :CONNECT REM echo %host% REM echo %user% REM echo %fgcolor% REM echo %bgcolor% REM echo %comp% run xterm -sl 1000 -sb -rightbar -fg %fgcolor% -bg %bgcolor% -title "%host%" -n "%host%" -e "ssh -Y %comp% %host% -l %user%" :END REM pause It doesn't ask for a password when using this batch file, because we've setup ssh on the Windows PC to be an authorized host on the Unix/Linux servers. See "man ssh" for more details on secure shell. Secure shell is part of the Cygwin distribution, and ssh-keygen is the program to create encrypted keys for passwordless authorization. 3. Once logged into fuu-220 "uname -a" reveals that it is a Linux box, and you can run shell commands (top) and X-Windows programs (xcalc). 4. From that window, "ssh fuu-239" brings us to another Linux server and from there we run "xcdroast" with no need to set DISPLAY variables and "xhost +" because ssh is setup to do X11Forwarding through the secure connection. 5. From there, "rsh nfs1" takes us over to a Sun workstation, where we could run Rolls Royce/EDS key Unix systems. 6. Double-clicking a shortcut to "HP Server (fus-121)" brings up a terminal to that particular machine. The shortcut command looks like this: "E:\My Documents\scripts\xterm.bat" fus-121 itdb1 gold Then "uname -a" reveals that we connected to an HP/UX workstation. We can run terminal commands or X-Window programs (xcalc). 7. We double-click a shortcut to "edsnet" to connect to an IBM mainframe system. The shortcut is a bat file that looks like this: @echo off SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB SET XNLSPATH=/usr/X11R6/lib/X11/locale run x3270 edsnet This script runs an X-Windows 3270 emulator to connect to EDSNET. 8. We kill the local X-Server, by right-clicking on the "X" in the icon tray and clicking exit. 9. We show that we can use Linux commands within a Cygwin bash shell window to "rsync" files from "My Documents" to a linux server. Clicking "Backup My Documents" runs the following script: @echo off C: chdir C:\cygwin\bin bash -c "/usr/bin/rsync -av -e ssh --delete \"/cygdrive/e/My Documents\" root@fuu-220:/backups bash -c "/usr/bin/rsync -av -e ssh --delete \"/cygdrive/c/Program Files/Microsoft Visual Studio/MyProjects\" root@fuu-220:/backups pause This script copies all my C++ source code and personal documents to a directory on fuu-220 (a Linux box) called "backups." This is great for backing up files at home to a portable USB drive, or at work to a system which gets backed up nightly via magnetic tape. 10. The final demonstration is running a remote XServer to get a full login screen to a Linux workstation. Double-clicking "Remote Linux (fuu-220)" runs the following bat file: C: chdir C:\cygwin\bin bash --login -i -c "Xwin.exe -query %1" This takes a single parameter as the hostname to "query." That host must be running xdm, gdm or some other display manager and XDMCP must be enabled. On a Fedora Linux system that is done using "gdmconfig." Once logged in you get a full screen just as if you had logged in to the console, and from there you can run any installed program. In conclusion, Cygwin and Cygwin/X are very very powerful tools for Windows to Unix/Linux connectivity and to top it off, they are GNU FREE AS IN FREEDOM! See also http://www.oreilly.com/openbook/freedom/ See also http://www.cygwin.com/ See also http://x.cygwin.com/ See also http://xlivecd.indiana.edu/ Contact: David (Doc) Brown doc.brown@eds.com