Movatterモバイル変換


[0]ホーム

URL:


Using Cygwin effectively with Windows
Prev Chapter 3. Using Cygwin Next

Using Cygwin effectively with Windows

Cygwin is not a full operating system, and so must rely on Windows foraccomplishing some tasks. For example, Cygwin provides a POSIX viewof the Windows filesystem, but does not provide filesystem drivers of its own. Therefore part of using Cygwin effectively is learning to useWindows 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, andnet.exe views and configuresnetwork file and printer resources. Most of these toolssupport the/? switch to display usage information.

Unfortunately, no standard set of tools included with all versions of Windows exists. Generally, the younger the Windows version, the morecomplete are the on-board tools. Additionally, many independentsites such asdownload.com,simtel.net, and Microsoft's ownSysinternalsprovide quite useful command-line utilities, as far as they are notalready provided by Cygwin. A few Windows tools, such asfind.exe,link.exe andsort.exe, may conflict with the Cygwin versionsmake sure that you use the full path (/usr/bin/find)or that your Cygwinbin directory comes first in yourPATH.

Pathnames

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 thecygpath utility for converting between Windows and POSIX paths. A complete description of its options and examples of its usage are incygpath(1), 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, whichcygpath can translate from a POSIX path with the-p option. For example, a Java compilation frombash might look like this:

javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java

Since using quoting and subshells is somewhat awkward, it is often preferable to usecygpath in shell scripts.

Cygwin and Windows Networking

Many popular Cygwin packages, such asncftp,lynx, andwget, 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 youcan reach the URL's host withping.exe, one of the few utilities included with every Windows version since Windows 95.If you chose to install theinetutils package, you may have bothWindows and Cygwin versions of utilities such asftpandtelnet. If you are having problems using oneof 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 inrasdial.exe for automating dialupconnections. Users who frequently change their network configuration can script these changes withnetsh.exe.For proxy users, the open sourceNTLM Authorization Proxy Server or the no-chargeHummingbird SOCKS Proxy may allow you to use Cygwin networkprograms in your environment.

Creating shortcuts

By default, Cygwin does not create symlinks as .lnk files, but there's anoption to do that, seethe section called “TheCYGWIN environmentvariable”.These symlink .lnk files are compatible with Windows-created .lnk files,but they are still different. They do not include much of the informationthat is available in a standard Microsoft shortcut, such as the workingdirectory, an icon, etc. Thecygutilspackage includes amkshortcut utility for creatingstandard native Microsoft .lnk files from the command line.

But here's the problem. If Cygwin handled these native shortcuts like anyother symlink, you could not archive Microsoft .lnk files intotar archives and keep all the information in them. After unpacking, these shortcuts would have lost all the extra informationand would be no different than standard Cygwin symlinks. Therefore these twotypes of links are treated differently. Unfortunately, this means that the usual Unix way of creating and using symlinks does not work with nativeWindows shortcuts.

Printing

There are several options for printing from Cygwin, including thelpr found incygutils-extra(not to be confused with the native Windowslpr.exe).The easiest way to usecygutils-extra'slpr is to specify a default device name in thePRINTER environment variable. You may also specify a device on the command line with the-d or-P options, which will override the environment variable setting.

A device name may be a UNC path (\\server_name\printer_name), a reserved DOS device name (prn,lpt1), or a local port name that is mapped to a printer share. Note that forward slashes may be used in a UNC path (//server_name/printer_name),which is helpful when usinglpr from a shell that usesthe backslash as an escape character.

lpr sends raw data to the printer; no formatting is done.Many, but not all, printers accept plain text as input. If your printer supports PostScript, packages such asa2ps andenscript can prepare text files for printing. Theghostscript package also provides some translationfrom PostScript to various native printer languages. Additionally, a native Windows application for printing PostScript,gsprint, is available from theGhostscriptwebsite.


Prev Up Next
umount Home Chapter 4. Programming with Cygwin

[8]ページ先頭

©2009-2025 Movatter.jp