Re: How does one find cygdrive path in a Win .bat file (was Re: Bug in startXwin.bat)

2009-02-10 Thread Thorsten Kampe
* Linda Walsh (Mon, 09 Feb 2009 16:34:21 -0800)
 
 Larry Hall (Cygwin X) wrote:
  Linda Walsh wrote:
  The startxwin.sh script works, but startxwin.bat does not work if
  your Cygwin installation isn't in the default location.
 
  You could use mount -p (presuming your cygwin\bin is in your windows 
  path, as mine is).
 
  If not, need to look in the registry:
  \HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts 
  v2\cygdrive prefix
  
  No, you don't need to look in the registry.  There's nothing there that
  'mount' won't tell you.  Forget about the registry.  You'll be better
  off, especially when Cygwin 1.7 is released.
 ---
   I'm curious -- how does mount find or 'know' the cygdrive path
 if it doesn't come from the registry.

/etc/fstab
 
   For that matter, how would a windows .bat file find the
 'mount.exe' binary if the .bat file doesn't know 'cygdrive path'?

Mount is not a Cygwin application (meaning it doesn't have to know where 
cygwin1.dll is). So the bat file simply has to specify the path to 
mount.exe.

Thorsten


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



Re: How does one find cygdrive path in a Win .bat file (was Re: Bug in startXwin.bat)

2009-02-10 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Thorsten Kampe on 2/10/2009 2:01 AM:
  For that matter, how would a windows .bat file find the
 'mount.exe' binary if the .bat file doesn't know 'cygdrive path'?
 
 Mount is not a Cygwin application (meaning it doesn't have to know where 
 cygwin1.dll is). So the bat file simply has to specify the path to 
 mount.exe.

Wrong.  Mount _is_ a cygwin app.  But provided that /bin/mount and
/bin/cygwin1.dll are installed in the same directory (which they should
be), finding mount means you have found cygwin1.dll and thus have found /.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmRd6UACgkQ84KuGfSFAYDUjACgkMp3o9bAJdkm/zICWAR4r+GN
q/cAn1vHo3yrpj5h1mn7kx2ZEXHfyuBh
=ql/z
-END PGP SIGNATURE-

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



How does one find cygdrive path in a Win .bat file (was Re: Bug in startXwin.bat)

2009-02-09 Thread Linda Walsh

Larry Hall (Cygwin X) wrote:

Linda Walsh wrote:

The startxwin.sh script works, but startxwin.bat does not work if
your Cygwin installation isn't in the default location.

You could use mount -p (presuming your cygwin\bin is in your windows 
path, as mine is).


If not, need to look in the registry:
\HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts 
v2\cygdrive prefix


No, you don't need to look in the registry.  There's nothing there that
'mount' won't tell you.  Forget about the registry.  You'll be better
off, especially when Cygwin 1.7 is released.

---
I'm curious -- how does mount find or 'know' the cygdrive path
if it doesn't come from the registry.

For that matter, how would a windows .bat file find the
'mount.exe' binary if the .bat file doesn't know 'cygdrive path'?


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



Re: How does one find cygdrive path in a Win .bat file (was Re: Bug in startXwin.bat)

2009-02-09 Thread Larry Hall (Cygwin)

Linda Walsh wrote:

Larry Hall (Cygwin X) wrote:

Linda Walsh wrote:

The startxwin.sh script works, but startxwin.bat does not work if
your Cygwin installation isn't in the default location.

You could use mount -p (presuming your cygwin\bin is in your 
windows path, as mine is).


If not, need to look in the registry:
\HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts 
v2\cygdrive prefix


No, you don't need to look in the registry.  There's nothing there that
'mount' won't tell you.  Forget about the registry.  You'll be better
off, especially when Cygwin 1.7 is released.

---
I'm curious -- how does mount find or 'know' the cygdrive path
if it doesn't come from the registry.


How it finds it is an implementation detail.  There's no need to know
how it does what it does if it does what you want. ;-)  And, like I said,
the registry won't be used for 1.7 so anyone that uses this as a basis
of anything will find it broken once 1.7 is released.


For that matter, how would a windows .bat file find the
'mount.exe' binary if the .bat file doesn't know 'cygdrive path'?


That's a different issue.  However you imply a paradox that doesn't
exist.  Whether one knows the 'cygdrive path' or not will not make it
easier to find 'mount.exe'.  'mount.exe' is always in '/bin'.  As for
the issue of finding '/bin', there may be times when it is necessary
to script this, though I would say this is not one of those cases.
For those cases, searching the file-system or spelunking in the
registry are possible avenues, each with their own pluses and minuses.
In this case, just looking at 'cygwin.bat' will provide the answer
needed.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 893-9889 - FAX
Holliston, MA 01746

_

A: Yes.
 Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting annoying in email?

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



Re: How does one find cygdrive path in a Win .bat file (was Re: Bug in startXwin.bat)

2009-02-09 Thread Ralph Hempel

Here's how I do it in a little batch file that I put on
my USB pen drive:

It's in the attached .TXT file - you'll need to rename
it to .BAT

Note that this batch file will OVERWRITE your fstab so
please review it before installing and using it on your
system.

Basically, it lets me carry Cygwin on a USB stick and
it does not care what drive letter it's attached as.

Note also that USB sticks are slo, so it's just for
emergencies :-)

Ralph
@ECHO OFF
REM --
REM Batch file to start Cygwin on arbitrary drive letters

SETLOCAL
  FOR /F %%D IN (%CD%) DO SET CYGDRIVE=%%~dD

REM -- Check if we've already modified the fstab for this drive letter
  IF %CYGDRIVE%==%CYGWIN_DRIVE% GOTO :DONE

REM -- Check if the original fstab has been backed up
  IF EXIST %CYGDRIVE%\cygwinTest\etc\fstab.original GOTO MAKEFSTAB
copy %CYGDRIVE%\cygwinTest\etc\fstab 
%CYGDRIVE%\cygwinTest\etc\fstab.original

REM -- Set up the default fstab
:MAKEFSTAB
  echo # Custom fstab for removable media
%CYGDRIVE%\cygwinTest\etc\fstab
  echo # See /cygwin/etc/fstab.original for defaults
%CYGDRIVE%\cygwinTest\etc\fstab
  echo %CYGDRIVE%/cygwinTest /ntfs binary 0 0   
%CYGDRIVE%\cygwinTest\etc\fstab
  echo %CYGDRIVE%/cygwinTest/bin /usr/bin ntfs binary 0 0   
%CYGDRIVE%\cygwinTest\etc\fstab
  echo %CYGDRIVE%/cygwinTest/lib /usr/lib ntfs binary 0 0   
%CYGDRIVE%\cygwinTest\etc\fstab

rem -- Start up thedefault shell
  chdir %CYGDRIVE%\cygwinTest\bin
  bash --login -i

ENDLOCAL

:DONE

REM We're done with the local variables, but remember to set
REM a variable that tells us the drive Cygwin is running on

  SET CYGWIN_DRIVE=%CYGDRIVE%

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