|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
Softpanorama Search
|
Cygwin is a free software package that provides a Unix-like environment and software tool set in Windows environment (2000/XP/Vista). Cygwin was started in 1995 by Steve Chamberlain, an engineer working for Cygnus (later bough by by Red Hat). The earliest mailing list references on the Web are in early 1997, by which time it appears to have been in a functional state.
Cygwin is the most popular of server Unix-emulation packages available for windows. Among alternatives we can mention uwin -- free high quality implementation from AT&T which was led by David Korn (it includes ksh93). While discontinued Microsoft SFU version 3.5 is a high quality POSIX emulator for Windows.
It runs best on Windows XP/NT/2000 with NTFS, but will run in degraded mode with the FAT file system, and further degradation with Windows ME/98/95. Support for the latter will be dropped in version 1.7 (currently in beta).
Cygwin contains:
Cygwin consists of a Unix system call emulation library, cygwin1.dll, together with a set of GNU and other free software applications organized into a large number of optionally installed packages. Among these packages are a complete X11 development toolkit, GNU emacs, TeX and LaTeX, OpenSSH (client and server), and much more.
Due to presence of emulation layer cygwin (and especially Cygwin/X) is much slower then X servers which use native Win32 API.
Cygwin is not equivalent of a VMWare player and does not provide a means for running Linux binary executables under MS-Windows. In order to run such software using Cygwin, that software must be compiled from its sources. Cygwin provides all of the components needed to do this in most cases; most POSIX-compliant software, including X11 applications, can easily be ported to MS-Windows using Cygwin.
Teraterm is a reasonably good enough replacement for “cmd” and can serve as "out of the box" terminal for Cygwin. If you follow press Alt-G in Teraterm, you’ll get a terminal with the following advantages:
Cygwin provides POSIX view of the Windows file system space. The slash ('/') directory points to the system partition (C:) by default. In addition to selecting the slash partition, it allows mounting arbitrary Win32 paths into the POSIX file system space using mount command
mount [OPTION] [<win32path> <posixpath>]
Many people mount each drive letter under the slash partition (e.g. C:\
to /c, D:\ to /d, etc...). that is simpler that /cygdrive/c, /cygdrive/d,
etc). Here is additional information about optiond of the mount command
in Cygwin:
-b, --binary (default) text files are equivalent to binary files (newline = \n)
-c, --change-cygdrive-prefix change the cygdrive path prefix to <posixpath>
-f, --force force mount, don't warn about missing mount point directories
-h, --help output usage information and exit
-m, --mount-commands write mount commands to replicate user and system mount points and cygdrive prefixes
-o, --options X[,X...] specify mount options
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix
-s, --system (default) add system-wide mount point
-t, --text text files get \r\n line endings
-u, --user add user-only mount point
-v, --version output version information and exit
-x, --executable treat all files under mount point as executables
-E, --no-executable treat all files under mount point as non-executables
-X, --cygwin-executable treat all files under mount point as cygwin executables
Path translations can be done by executing the cygpath utility program
Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME... cygpath [-c HANDLE] cygpath [-ADHOPSW] cygpath [-F ID] Convert Unix and Windows format paths, or output system path information Output type options: -d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\) -m, --mixed like --windows, but with regular slashes (C:/WINNT) -M, --mode report on mode of file (currently binmode or textmode) -u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt) -w, --windows print Windows form of NAMEs (C:\WINNT) -t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows' Path conversion options: -a, --absolute output absolute path -l, --long-name print Windows long form of NAMEs (with -w, -m only) -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin') -s, --short-name print DOS (short) form of NAMEs (with -w, -m only) System information: -A, --allusers use `All Users' instead of current user for -D, -P -D, --desktop output `Desktop' directory and exit -H, --homeroot output `Profiles' directory (home root) and exit -O, --mydocs output `My Documents' directory and exit -P, --smprograms output Start Menu `Programs' directory and exit -S, --sysdir output system directory and exit -W, --windir output `Windows' directory and exit -F, --folder ID output special folder with numeric ID and exit Other options: -f, --file FILE read FILE for input; use - to read from STDIN -o, --option read options from FILE as well (for use with --file) -c, --close HANDLE close HANDLE (for use in captured process) -i, --ignore ignore missing argument -h, --help output usage information and exit -v, --version output version information and exitThe cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style pathnames and vice versa. It can be used when a Cygwin program needs to pass a file name to a native Windows program, or expects to get a file name from a native Windows program. Alternatively, cygpath can output information about the location of important system directories in either format.
The
-uand-woptions indicate whether you want a conversion to UNIX (POSIX) format (-u) or to Windows format (-w). Use the-dto get DOS-style (8.3) file and path names. The-moption will output Windows-style format but with forward slashes instead of backslashes. This option is especially useful in shell scripts, which use backslashes as an escape character.In combination with the
-woption, you can use the-land-soptions to use normal (long) or DOS-style (short) form. The-doption is identical to-wand-stogether.Caveat: The
-loption does not work if the check_case parameter of CYGWIN is set to strict, since Cygwin is not able to match any Windows short path in this mode.The
-poption means that you want to convert a path-style string rather than a single filename. For example, the PATH environment variable is semicolon-delimited in Windows, but colon-delimited in UNIX. By giving-pyou are instructing cygpath to convert between these formats.The
-ioption supresses the print out of the usage message if no filename argument was given. It can be used in make file rules converting variables that may be omitted to a proper format. Note that cygpath output may contain spaces (C:\Program Files) so should be enclosed in quotes.Example 3.5. Example cygpath usage
#!/bin/sh if [ "${1}" = "" ]; then XPATH="."; else XPATH="$(cygpath -w "${1}")"; fi explorer $XPATH &The capital options
-D,-H,-P,-S, and-Woutput directories used by Windows that are not the same on all systems, for example-Smight output C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM. The-Hshows the Windows profiles directory that can be used as root of home. The-Aoption forces use of the "All Users" directories instead of the current user for the-D,-Oand-Poptions. The-Foutputs other special folders specified by their internal numeric code (decimal or 0xhex). For valid codes and symbolic names, see the CSIDL_* definitions in the include file /usr/include/w32api/shlobj.h from package w32api. The current valid range of codes for folders is 0 (Desktop) to 59 (CDBurn area). On Win9x systems with only a single user,-Ahas no effect;-Dand-ADwould have the same output. By default the output is in UNIX (POSIX) format; use the-wor-doptions to get other formats.
Win32 file systems are case preserving but case insensitive. Cygwin does not currently support case distinction because, in practice, few UNIX programs actually rely on it.
Symbolic links are emulated by files containing a magic cookie followed by the path to which the link points. They are marked with the System attribute so that only files with that attribute have to be read to determine whether or not the file is a symbolic link. Hard links are fully supported under Windows NT on NTFS file systems.
The inode number for a file is calculated by hashing its full Win32 path. The inode number generated by the stat call always matches the one returned in d_ino of the dirent structure. It is worth noting that the number produced by this method is not guaranteed to be unique. However, we have not found this to be a significant problem because of the low probability of generating a duplicate inode number.
Cygwin provides the following functionality for WIN32 applications:
|
|||||||
March 13, 2005 | users.soe.ucsc.edu/~you
May 2, 2007 | www-cdf.fnal.gov
Mrxvt
rxvt is an xterm-like terminal program. mrxvt is built from the same code base, but adds tabs (similar to konsole terminals in KDE). It turns out building these for Cygwin (assuming you have the X11 libraries installed) is very easy.
Note: I recommend building mrxvt from source, but for those who want to try a built version, you can grab mine. I also have a perl script, mrxvt_options.pl, that lets you change the names of tabs, etc. mrxvt.bat (assuming you put mrxvt.exe in c:\cygwin\bin) will start it up for you.
- Visit the mrxvt home page
- Read the README file.
- Download the source.
- Untar the source file
cygwin> tar xzf mrxvt_0.40.tar.gz
- Configure as shown in the readme file
cygwin> ./configure --enable-everything --disable-debug
- Make and install
cygwin> make && make installYou should be good to go. Here are the entries I have in my ~/.Xdefaults file:
!############## !# mrxvt !############## mrxvt*font: 6x13 mrxvt*foreground: white mrxvt*background: black mrxvt*scrollbarStyle: rxvt ! These keys are used by emacs, disable them mrxvt*hotkey*Dummy: Ctrl+Shift+underscore mrxvt*hotkey*Dummy: Ctrl+Shift+plusInstalling Perl TkNote: As of December 2005, you can download Tk from any Cygwin mirror using the cygwin installer. I recommend trying this first before building your own.
Perl Tk is a useful GUI addition to the Perl language. In my Useful files tar ball, you will find a few scripts that take advantage of this package. It is, however, by no means necessary, so feel free not to install it (or install it later). Note: I have always installed Perl Tk 8.00.024. There are newer versions; I just haven't tried them. If you're curious, please try and let me know how it goes. If you want to be lazy and play it safe, follow the directions below. I'm assuming that you have a full cygwin installation as shown above.
You should now be good to go. Console GUI The console GUI is a Perl Tk script that I wrote that makes it easy to log into many different machines. You can find it in the tgz above.
- Open a new Cygwin window and fix a problem with Perl
cygwin> cd /usr/X11R6/lib
cygwin> ln -s libX11.dll.a libX11.a
Close the window.
Note: I've been told that you don't need to do this step anymore, but I haven't verified that yet.- Grab the source of Tk-800.024.tar.gz and save it somewhere cygwin can see it (e.g. c:\cygwin\home\yourname\Tk-800.024.tar.gz).
- Open a window in Cygwin and untar and feather it:
cygwin> tar xzf Tk-800.024.tar.gz- Log into the new directory
cygwin> cd Tk800.024- Read the README.cygwin file
- Configure the makefile as specified in the readme file
cygwin> perl Makefile.PL x- Start the build
cygwin> make- It has always worked for me. Hopefully it will work for you. If the build is successful, install it
cygwin> make install
- Take all files in the bin/ directory and copy them to your bin dir. Copy also the .console.properties file (a directory up) to your home area.
- I have the shortcut I use to start the console script (Console.lnk). Right-click on the link and save it to your desktop. You will have to edit this shortcut to point to your version.
- Right-click on the icon and choose properties.
- Edit the Target and replace /home/cplager with /home/yourname
- The shortcut also assumes that run.exe is in /bin, so copy it there
cygwin> cp /usr/X11R6/bin/run.exe /bin/- Summary of Commands:
- l/L - start Local xterm
- x/X - start xterm as you on machine selected
- o/O - start xterm as other on machine selected
- The console GUI is configurable. Edit the .console.properties file for details.
- If your cygwin username does not match your FNAL username (a bad idea, but it happens), you will need to:
- Add a line in the .console.properties
- user fnalUserName- Edit bin/kinit.pl file where you add what is in red
system "/bin/kinit -n -l 100d fnaluser@FNAL.GOV";
June 3, 2009 | zenovations.com
After repeated problems setting up crond to run in cygwin (it just doesn’t like the user accounts, no matter how enthusiastically I argue that I’m me), I spent some time figuring out how to run a Cygwin command as a scheduled task from Windows scheduler. Here is what I figured out.
Based on this mail archive post, I created the following cygrun.bat file:
@echo off rem set HOME=c:\ if "%DEF_PATH%"=="" set DEF_PATH=%PATH% set PATH=c:\cygwin\bin;%DEF_PATH% set myargs=%* if "%myargs%" == "" goto noarg rem echo %myargs% bash --rcfile %HOME%/.bashrc -i -c "%myargs%" c: rem pause sleep 1 goto exit :noarg rxvt -e /usr/bin/bash --login -i :exit exitThen I tested the script from the command line as follows, until I had the syntax just so:
c: cd \cygwin cygrun.bat cygwin_script arg1 arg2Once I was able to run it happily, I added the scheduled task as follows:
Run: C:\WINDOWS\system32\CMD.EXE /x /c start "Some title" /min c:\cygwin\cygrun.bat cygwin_script arg1 arg2 Start In: c:\cygwin <-- must be a real disk drive and path Run as: domain\usernameUnfortunately, I was never able to figure out how to redirect stdout and stderr. I tried plenty of variations on “>> /some/path/to/log.txt 2>&1″ with no joy. Instead, I just changed all the commands in the script and added that line on to each echo statement. Sad, but functional.
See also Better Cygwin Terminal
Bash Shell can also be run through the Cygwin's rxvt terminal distributed with cygwin. It is a colour vt102 terminal emulator intended as an xterm replacement. It can be launched without starting any X Window System. The terminal has some nice feature including familiar cut and paste operations (familiar to Unix users). It also offers better fonts.
Rxvt can be started by typing the following command in a command prompt window.
D:\Programs\Cygwin\bin\rxvt.exe -sl 500 -fn courier -bg wheat -sr -title "Bash Sailor" -e D:\Programs\Cygwin\bin\bash.exe --rcfile %HOME%\.bashrc
Among files
Thu Oct 9 00:36:24 2003 1249 usr/share/doc/Cygwin/d-1.2.0.README
Thu Oct 9 00:36:25 2003 0 usr/share/doc/d-1.2.0/
Thu Oct 9 00:36:25 2003 17992 usr/share/doc/d-1.2.0/COPYING
Thu Oct 9 00:36:25 2003 5685 usr/share/doc/d-1.2.0/d.conf.example
Thu Oct 9 00:36:25 2003 445 usr/share/doc/d-1.2.0/README
Thu Oct 9 00:36:24 2003 0 usr/share/info/
Thu Oct 9 00:36:24 2003 17027 usr/share/info/d.info
Thu Oct 9 00:36:24 2003 0 usr/share/man/
Thu Oct 9 00:36:25 2003 0 usr/share/man/man1/
Thu Oct 9 00:36:25 2003 1915 usr/share/man/man1/d.1
Here is example of Tree printing
[0] [BezrouN@USBT92DD1:~] $ d -T /home/bezroun/: |-etc/: | |-Hosts/: | |-DIR_COLORS | |-DIR_COLORS.xterm | |-aix_functions | `-dir_history |-telnet_test.pl `-telnet_test.pl~
Princeton University
Use the following steps to successfully get OpenSSH working as a server:
- Set up your environment for Cygwin. For NT 4 and Windows 2000, this is done by right-clicking on My Computer and choosing Properties. In NT4, it's on the Environment tab. In Windows 2000, it's the Environment Variables on the Advanced tab. Add the following setting to the System Environment:
Append the following variable to contain the following:
- CYGWIN = ntsec tty
Note that if you are NT/2K on FAT(32), the ntsec option for the CYGWIN variable won't help you much. In these cases, just set CYGWIN to "tty". (Note: Through email, I've been notified that having CYGWIN=ntsec actually does made a difference on FAT(32) systems. Geoffrey Hoo)
- Path : ;C:\Cygwin\bin
- Download the Cygwin Setup Program into a temporary folder like C:\CygwinInstall.
- Run "C:\CygwinInstall\Setup.exe", choose " Install from Internet ", choose a suitable mirror (I like "ftp://mirrors.rcn.net").
- Now choose the packages you want to install. Click on the "+" next to "Admin" to expand it. Click on the word "Skip" next to the word cygrunsrv to install the NT/Win2k/XP Cygwin Service Initiator. Install cygwin-doc from "Doc", nano and/or vim from "Editors" and openssh from "Net".
- [Optional] After Setup is complete, I like to make a couple of changes to the default installation: - Download and install ftp://ftp.erdelynet.com/mike/cygwin/profile, ftp://ftp.erdelynet.com/mike/cygwin/sh_aliases into /etc. - Change the Cygwin icons so that, instead of pointing to cygwin.bat, they point to "c:\cygwin\bin\bash.exe --login -i" and start in "c:\cygwin\bin"
NOTE: Unless specified otherwise, run the following commands within the Cygwin Bash Shell installed in your Start Menu.
- Now, you'll want to configure sshd. This is MUCH simpler than it used to be.
Run "ssh-host-config -y" to set it up. This step will create necessary configuration files, a priviledge separation user and necessary directories. When prompted with "CYGWIN=" type what you set CYGWIN to in step 1 (tty ntsec).
- You will probably want to change permissions and ownership on some files:
- cd /; chmod -R og-w .
- chmod og+w /tmp
- touch /var/log/sshd.log
- chown system:system /var/log/sshd.log /var/empty /etc/ssh_h*
- chmod 755 /var/empty
- Now you are ready to start the service: "cygrunsrv -S sshd"
- Test the service by running "ssh localhost"
SecurityForest
Tutorial by Loni
How-to setup an SSH daemon using Cygwin (Only tested on windows 2000)Make sure you install the following:
Admin -> Cygrunsrv Net -> OpenSSHEdit the cygwin.bat file and add the CYGWIN environmental variable
notepad d:\cygwin\cygwin.bat add the following: set CYGWIN=binmode tty ntsecStart a cygwin bash console
Configure SSH
# ssh-host-config Should privilege separation be used? (yes/no) no Do you want to install sshd as service? (yes/no) yesNow you have a choice of the service being automatically or manually started
Automatically Started:# cygrunsrv -S sshdManually Started:# net start sshd # net stop sshd
OpenSSH for Windows is a free package that installs a minimal OpenSSH server and client utilities in the Cygwin package without needing the full Cygwin installation.The OpenSSH for Windows package provides full SSH/SCP/SFTP support. SSH terminal support provides a familiar Windows Command prompt, while retaining Unix/Cygwin-style paths for SCP and SFTP.
Note : This set of instructions has worked for me at our institution. You should read /usr/share/doc/Cygwin/openssh.README after installing cygwin and check the cygwin mailing list if you encounter problems.
PuTTYcyg is a patched version of PuTTY that, in addition to telnet, rlogin, ssh, and serial connections, can also be used as a local Cygwin terminal instead of the Windows console or xterm. See README.txt for more information.
Download the latest release (20071202).
PuTTYcyg may require a recent version of Cygwin. PuTTYcyg version 20071202 has been tested with version 1.5.24-2 of cygwin1.dll and several users report success with 1.5.25.
Problems? Please read the (very short) FAQ and the (very short) README before filing an issue.
v1.07 - 2006/11/26 Copyright(C) 2000-2006 NSym.
= Japanese / English =Overview of CygTerm
In Cygwin, you can use a shell such as bash on the DOS window.
However, using on the DOS window is inconvenient when you want to do window resizing, copy & paste, or etc.
I guess many people may use Unix machines with a terminal emulator via Telnet.
It is convenient to use Cygwin in the same way as it, that is to operate with a VT100 terminal emulator.
At first you think that preparing inetd, in.telnetd and so on in Cygwin and login from a terminal emulator...
But, here is another approach.
In short it is to connect a terminal emulator and Cygwin shell directly.
You simply use a terminal emulator instead of cygwin.bat DOS window without login.Idea
The idea is to make a program which performs starting a terminal emulator and Cygwin shell, and relaying their I/O.
When you run this program a specified terminal emulator starts up and the Cygwin shell command line prompt appears in it.
screen shotDesign
Details of cygterm.exe [1] Prepare a listener socket to wait for a TELNET connection. Find out an unused TCP port number to assign to the socket from a specified range. [2] Invoke a terminal emulator in another thread. Then specify IP address `127.0.0.1' and the port number [1] in the command line arguments. [3] Accept the connection from the terminal emulator. Refuse it except a connection from `127.0.0.1' in security. [4] Do fork(), and in the child process, invoke a shell under PTY (pseudo terminal) slave side. [5] Relay I/O between the TELNET connection socket [3] and the PTY master side of [4]. Support for TELNET protocol (options negotiation) Receive the notification of terminal-type from a terminal emulator, and apply it to the environment variable TERM on a shell. Receive the notification of terminal-size from a terminal emulator, and apply it to window size of PTY. [Ref. RFC854 TELNET PROTOCOL SPECIFICATION] cygterm.exe is implemented as an window-less Win32 application.Download
Source FilesREADME - description file README-j - original README in Japanese Makefile - MAKEFILE for installation cygterm.cc - program source code cygterm.cfg - configuration filedownload cygterm107.tgz (about 14kb) [for Cygwin-1.5.5-22+gcc-3.4, newer]
download cygterm106.tgz (about 13kb)--- License ---
CygTerm is a free software distributed under the terms of the GNU General Public License (GPL)
published by Free Software Foundation. See GPL (http://www.gnu.org/copyleft/gpl.html).
--- Note ---
Any program including non-GPL program can invoke the CygTerm executable (cygterm.exe) and communicate with it.
Install
Do `make install' under Cygwin.
- - - - - - - - - -
Be sure to specify the install directory by BINDIR in Makefile in advance.
cygterm.exe and cygterm.cfg are installed in BINDIR. cygterm.cfg is not overwritten.
Configuration
cygterm.cfg is a configuration file.
This includes definitions for the command lines of a terminal emulator and a shell, and several parameters.
cygterm.cfg is loaded from the same directory cygterm.exe exists in.
An example of cygterm.cfg +----------------------------------------------------------------------- | TERM = C:\program files\ttermpro\ttermpro.exe %s %d /KR=SJIS /KT=SJIS | TERM_TYPE = vt100 | PORT_START = 20000 | PORT_RANGE = 40 | SHELL = /bin/bash | ENV_1 = MAKE_MODE=unix | ENV_2 = HOME=/home | : : TERM This is the command line to execute a terminal emulaitor. Specify the full path to the command if it isn't in Windows search path. This needs to be described `%s' and `%d' for the host and port number. TERM_TYPE This terminal type is adopted when the terminal emulator did not give a terminal type. (default: vt100) Then this value is set to the environment variable TERM on a shell. PORT_START This is the minimum TCP port number allowed for use. (default: 20000) PORT_RANGE This is the maximum number of TCP ports allowed for use. (default: 40) cygterm.exe looks for an unused port number between PORT_START and PORT_START+PORT_RANGE, and therefore can be run concurrently as many as this number. SHELL This is the command line to execute a shell in Cygwin side (normally /bin/bash). Specify the full path to the shell. ENV_X This is the environment variable to be set when starting the shell. It should be of the form `name=value' (like putenv). It is possible to give as many environment variables as needed by beginning with "ENV_".
Usage
Command Line Options cygterm.exe [-t 'terminal-emulator'] [-p port-number] [-dumb] [-s 'shell'] [-v 'env-var' ...] -t 'terminal-emulator' Specify the command line of a terminal emulator to execute. This format is the same as TERM in the configuration file. The command line should be enclosed in quotes to include spaces. -p port-number Instead of executing a terminal emulator, try connection to this port number of localhost. It is considered another program uses `-p' option to use Cygwin via cygterm.exe. -dumb Suppress the TELNET options negotiation. And ignore any TELNET commands sent from terminal side. The environment variable TERM is set to `dumb' on the shell side. -s 'shell' Specify the command line of a shell on Cygwin to execute. This format is the same as SHELL in the configuration file. The command line should be enclosed in quotes to include spaces. Any command can be specified even if a non-shell command. -v 'env-var' Specify the environment variable to be set when starting the shell. This format is the same as ENV_X in the configuration file. The expression should be enclosed in quotes to include spaces. One or more `-v' options are available.The terminal emulator or connection port number, and the shell on Cygwin, these need to be specified at least.
If these are given in the command line, cygterm.exe can be run without configuration file cygterm.cfg.
Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
Last modified: November 18, 2009