That is great. Thanks for your patient.
I have another question. Can the first field of fstab use relative
path. I expect to make the cygwin portable, that is, i need to move it
to somewhere esle without changing the fstab every time.

If you are using Cygwin in portable mode (presumably on a stick or similar 
mobile device)
there is a way to achieve what you want - but it is fiddly.
I am guessing that Cygwin is mounted at the root of your device ie /bin, /etc, 
/usr, and
all the rest are all located under d: or f: or g: or p: or whatever the device 
might turn out
to be labelled as you move from one host machine to another host machine, and 
that you do not
want the grief of having to identify the variant drivename every time and 
manually re-configure
the line in /etc/fstab as

f:/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0 or
        h:/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0  

accordingly, as might be necessary.

The way I do it (if_there_is_a_better_way_I_would_like_to_know_it) is to start 
portable Cygwin with
a .cmd file (called go.cmd or something) that resides at the root of the device 
and starts with the
lines

@set DOS_CMD=%0
@set CWD=%CD%
@set DN=%CWD:~0,2%
@if (%DOS_CMD:~1,1%)==(:) set DN=%DOS_CMD:~0,2%
@if (%DOS_CMD:~2,1%)==(:) set DN=%DOS_CMD:~1,2%

All this is designed so that the variable DN (standing for drivename) is 
exactly D: or F: or G:
or P: as appropriate, and the reason for the five lines is so that this 
identification is
correctly made however you start Cygwin, whether by

(i)   typing go.cmd at the prompt in a Command Prompt window located at F:
(ii)  typing f:\go.cmd at the prompt in a Command Prompt window located 
somewhere else
(iii) double clicking the go.cmd icon in Explorer
(iv)  using Start -> Run -> f:\go.cmd

Yeah, I know, all that effort just so that DN accurately identifies the 
drivename, but it all has to
be done BEFORE Cygwin is triggered. You can then go on, still in go.cmd, to say 
something like

@%DN%\bin\echo %DN%/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0 >  
%DN%\etc\fstab
... any other requirements ...                                  >> 
%DN%\etc\fstab

and then, FINALLY, start Cygwin with (well, in my case: your requirement might 
differ)

@set SHELL=/bin/bash
@set HOME=/home/user
@%DN%\bin\rxvt

Awfully sorry for long post. A fiddly way to get something rather simple, but 
it works in all of
W98, XP, Vista and 7. And there are lots of other reasons (if you are running portable Cygwin off one device on any number of potential host machines) why you might want to use DN without having to discover it (or, in fact, even know it) each time.
Fergus



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to