This is the mail archive of the
mailing list for the Cygwin project.
"Using Cygwin Effectively with Windows" -- Draft of new User's Guide section
- From: Joshua Daniel Franklin <joshuadfranklin at yahoo dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 30 Jul 2003 11:18:07 -0700 (PDT)
- Subject: "Using Cygwin Effectively with Windows" -- Draft of new User's Guide section
I've thrown together a prospective "Using Cygwin Effectively with Windows"
section for the User's Guide.
If you'd like to look at it as a web page:
I'm going to be leaving this broadband connection in under 48 hours,
so I'll probably put this into CVS tomorrow (with any corrections)
unless there is a horrendous outcry against it. Then I'll be in and
out of contact for probably a(nother) couple of weeks while I move.
--Q: Does anyone know of a page that lists command line configuration
utilities included with Windows 95/98/ME vs. Windows NT4/2000/XP?
--FYI: There are links to outside sites like download.com, Hummingbird's
free-beer SOCKS proxy, etc.
--Documentation of printing is sparse since I don't really do it much.
Does anyone have extensive documentation of their complex setup?
--There's basically nothing on Java except a sample about translating
the CLASSPATH to DOS format. I'm not sure what else to put in. There are
no Cygwin-native java compilers, right?
Joshua Daniel Franklin
Attached is the text.
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
Cygwin User's Guide
Chapter 3. Using Cygwin
Using Cygwin effectively with Windows
Cygwin is not a full operating system, and so must rely on Windows for accomplishing some tasks. For example, Cygwin provides a POSIX view of the Windows filesystem, but does not provide filesystem drivers of its own. Therefore part of using Cygwin effectively is learning to use Windows effectively. Many Windows utilities provide a good way to interact with Cygwin's predominately command-line environment. For example, ipconfig.exe provides information about network configuration, and net.exe views and configures network file and printer resources. Most of these tools support the /? switch to display usage information.
Unfortunately, there is no standard set of tools included with all versions of Windows. If you are unfamiliar with the tools available on your system, here is a general guide. Windows 95, 98, and ME have very limited command-line configuration tools. Windows NT 4.0 has much better coverage, which Windows 2000 and XP expanded. Microsoft also provides free downloads for Windows NT 4.0 (the Resource Kit Support Tools), Windows 2000 (the Resource Kit Tools), and XP (the Windows Support Tools). Additionally, many independent sites such as download.com, simtel.net, and sysinternals.com provide command-line utilities.
Cygwin and Windows Console Programs
There are several challenges to using Cygwin with Windows console programs. Most obviously, Windows programs do not understand POSIX pathnames, so any arguments that reference the filesystem must be in Windows (or DOS) format or translated. Cygwin provides the cygpath utility for converting between Windows and POSIX paths. A complete description of its options and examples of its usage are in the section called Cygwin Utilities, including a shell script for starting Windows Explorer in any directory. The same format works for most Windows programs, for example
notepad.exe "$(cygpath -aw "Desktop/Phone Numbers.txt")"
A few programs require a Windows-style, semicolon-delimited path list, which cygpath can translate from a POSIX path with the -p option. For example, a Java compilation might look like this:
javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java
Since using quoting and subshells is somewhat awkward, it is often preferable to use cygpath in shell scripts.
Another issue is receiving output from or giving input to the console-based Windows programs. Unfortunately, interacting with Windows console applications is not a simple matter of using a translation utility. Windows console applications and designed to run under command.com or cmd.exe, and some do not deal gracefully with other situations. Cygwin can receive console input only if it is also running in a console (DOS box) since Windows does not provide any way to attach to the backend of the console device. Another traditional Unix input/output method, ptys (pseudo-terminals), are supported by Cygwin but not entirely by Windows. The basic problem is that a Cygwin pty is a pipe and some Windows applications do not like having their input or output redirected to pipes.
To help deal with these issues, Cygwin supports customizable levels of Windows verses Unix compatibility behavior. The most compatible with Windows programs would be to use a DOS prompt, running only the occasional Cygwin command or script. Next would be to run bash with the default DOS box. To make Cygwin more Unix compatible, set CYGWIN=tty (see the section called The CYGWIN environment variable) and run a Unix shell in rxvt.exe, an optional package available from setup.exe.
Cygwin and Windows Networking
Many popular Cygwin packages, such as ncftp, lynx, and wget, require a network connection. Since Cygwin relies on Windows for connectivity, if one of these tools is not working as expected you may need to troubleshoot using Windows tools. The first test is to see if you can reach the URL's host with ping.exe, one of the few utilities included with every Windows version since Windows 95. If you chose to install the inetutils package, you may have both Windows and Cygwin versions of utilities such as ftp and telnet. If you are having problems using one of these programs, see if the alternate one works as expected.
There are a variety of other programs available for specific situations. If your system does not have an always-on network connection, you may be interested in rasdial.exe (or alternatives for Windows 95, 98, and ME) for automating dialup connections. Users who frequently change their network configuration can script these changes with netsh.exe (Windows 2000 and XP). For proxy users, the open source NTLM Authorization Proxy Server or the no-charge Hummingbird SOCKS Proxy may allow you to use Cygwin network programs in your environment.
The cygutils package
The optional cygutils package contains miscellaneous tools that are small enough to not require their own package. It is not included in a default Cygwin install; select it from the Utils category in setup.exe. Several of the cygutils tools are useful for interacting with Windows.
One of the hassles of Unix-Windows interoperability is the different line endings on text files. As mentioned in the section called Text and Binary modes, Unix tools such as tr can convert between CRLF and LF endings, but cygutils provides several dedicated programs: conv, d2u, dos2unix, u2d, and unix2dos. Use the --help switch for usage information.
Another problem area is between Unix-style links (or symlinks) and Windows links (or shortcuts). The Cygwin symlinks are pretty simple. They only contain the information needed to point to something else. Shortcuts created by native Windows applications (like Explorer) might contain a lot more of information, such as the working directory, an icon, etc. If Cygwin would handle these native shortcuts like any other symlink, you would have a problem. For instance, you couldn't archive these shortcuts into tar archives and keep all the information in them. After unpacking, these shortcuts would be no different than standard Cygwin shortcut symlinks, so they would have lost all these extra information. Therefore these two types of links differently. Unfortunately, this means that the usual Unix way of creating and using symlinks does not work with Windows shortcuts. The cygutils package includes a mkshortcut utility for creating Windows shortcuts.
Printing from Cygwin can also be a challenge. There are many options, including ghostscript, native Windows lpr.exe, and the simlple lpr found in cygutils. The cygutils version accepts network printer names in backslash notation (\\COMPUTER\Printer Share), which must be escaped from shells such as bash (\\\\COMPUTER\\Printer Share). If you have a command in a script such that it may be processed twice by the shell, you may need to double-escape the name (\\\\\\\\COMPUTER\\\\Printer Share). Another solution is to set the PRINTER environment variable to your local printer name.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html