Red Antigua Logo
Yet another piece of web.
Search this site (by Google)
Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
MSYS2 - UNIX environment for MS Windows 32/64 bits
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

MSYS - UNIX-styled shell on Windows
MSYS - UNIX-styled shell on Windows

This software is obsolete.
Use MSYS2 instead.



MSYS Homepage: http://www.mingw.org/wiki/msys
Download: https://sourceforge.net/projects/mingw/files/

Install
First, install MinGW.
Then, start the MSYS Installer as for any other Windows program.
Choose the default option whenever you asked to.
In the post-install session (a DOS prompt), you will be asked if MinGW is installed.
Type 'y' on all questions.
To run a MSYS shell, just click the MSYS desktop icon (created by default).

Configure (optional)
To run MSYS there is really no configuration needed.
MSYS is installed by default in the folder C:\MSYS\1.0, and binaries will be found in C:\MSYS\1.0\bin.
There is no need to add this path to the PATH Environment variable.
Let's assume you are logged in on Windows as user me:
$ pwd
/home/me
Just like in a UNIX shell session, the default directory is your home directory.

Using make and gcc
Check out the paths to the tools:
$ which gcc
/mingw/bin/gcc
MSYS uses its own make by default:
$ which make
/bin/make
If you want to use MinGW's make instead, you have to use its special name:
$ which mingw32-make
/mingw/bin/mingw32-make

Directory mapping and mount points
MSYS uses the following automatic mounts (that is, not configurable) in its directory layout:
MSYS directory mapping
Read all the details about how automatic points works in /doc/msys/README.rtf (that is, C:\msys\1.0\doc\msys\README.rtf outside MSYS), included in the MSYS distribution.

How to configure mount points manually
If we access C:\MSYS\1.0\mingw outside MSYS, we that this directory is (and should be) empty.
But when accessing /mingw in a MSYS shell, we see the following (assuming MinGW was installed before MSYS):
$ ls /mingw
COPYING      MinGW-5.1.3.exe  bin  include  installed.ini  libexec  mingw32
COPYING.LIB  MinGW.url        doc  info     lib            man      uninst.exe
This is because it is configured (automatically, during the MSYS installation) in /etc/fstab (that is, C:\msys\1.0\etc\fstab outside MSYS) as a user defined file system binding.
As the file name /etc/fstab indicates, this can be seen as a mount point.
(Or, if you prefer, as creating a "directory symlink".)

If you want to access other directories without using the full path, you can configure your own mount points.
Assume we have some source code in c:/Documents and Settings/Administrator/src that we want to access easily from within MSYS, without using the full path every time.
Create an empty directory C:\msys\1.0\home\me\src outside MSYS, or /home/me/src inside MSYS:
$ mkdir /home/me/src
Edit C:\msys\1.0\etc\fstab (use for example WordPad outside MSYS, or vi inside MSYS):
# Mount point created automatically during install
c:/MinGW /mingw

# Create a mount point for c:/Documents and Settings/Administrator/src on /home/me/src
c:/DOCUME~1/ADMINI~1/src /home/me/src
If you have any problems with configuring similar to the ones I experienced, read these notes:
# NOTE: 
# Different from UNIX, in MS Windows both source and destination directories have to exist.
# Source directory (c:/Documents and Settings/Administrator/src) will contain the files,
# destination directory (/home/me/src) must exist and be empty.
# /home/me/ is already mapped to c:/msys/1.0/home/me
# That means that C:\msys\1.0\home\me\src has to be created manually.
# This can be done either with Windows Explorer, or with the "mkdir src" command
# in a MSYS shell (in the /home/me directory).

# NOTE 2:
# When I just finished installing MSYS, I had problems to reflect changes in this file,
# even when closing a MSYS session and opening a new one.
# The solution was to restart Windows.
# Anyhow, this seems to be a one-time problem.
# From there and on, restart Windows is no longer needed, just close the MSYS session and open a new one.

# NOTE 3:
# I had problems using long names (with spaces) in path names.
# c:/Documents and Settings/Administrator/src /home/me/src    #DOES NOT WORK!
# c:/Documents\ and\ Settings/Administrator/src /home/me/src  #DOES NOT WORK!
# c:/DOCUME~1/ADMINI~1/src /home/me/src                       #WORKS!

# The solution was to find out the short name for the path.
# To do this, open a DOS prompt and type "dir /-N". 

Using third-party programs through wrapper scripts
There is no way to create a "file symlink" in MSYS in a way similar to a "directory symlink" (that is, a mount point).
The command ln for creating links works, but it actually makes a copy of the original file, not a symlink to it.
This is not what we want.
The solution is to create a wrapper script in /usr/local/bin.
The PATH environment variable in MSYS reflects the one configured in Window's Control Panel, with the MSYS and MinGW paths prepended:
$ echo $PATH
.:/usr/local/bin:/mingw/bin:/bin:/windows/configured/paths/go/here
As we see, first the current directory is searched, then /usr/local/bin/, then the MinGW path (/mingw/bin), then the MSYS path (/bin).
You can take advantage of the path /usr/local/bin being prepended to $PATH, to create your own shell script wrappers.
This way, you can call any Windows program without using the full path.

Create the /usr/local/bin directory if it doesn't exist:
mkdir -p /usr/local/bin
Example 1:
Create /usr/local/bin/wp, a wrapper for WordPad.exe:
#!/bin/sh
/c/Program\ Files/Windows\ NT/Accessories/wordpad.exe "$@"
Example 2:
Create /usr/local/bin/emacs, a wrapper for EmacsW32.exe (obviusly requires EmacsW32, how to install EmacsW32):
#!/bin/sh
/c/Program\ Files/Emacs/emacs/bin/emacsclientw.exe -n "$@"
Example 3:
Create /usr/local/bin/emacs-redantigua, a wrapper for EmacsW32.exe accessing a remote file/directory through plink (requires PuTTY, here is how to install PuTTY):
#!/bin/sh
/c/Program\ Files/Emacs/emacs/bin/emacsclientw.exe -n /plink:redantig@redantigua.com:/home/redantig/www/
Now you can edit any file from inside MSYS either with the command
wp <filename>
or
emacs <filename>
depending on your preferencies.

More info about mount points and scripts can be found in C:\msys\1.0\doc\msys\README.rtf, included in the MSYS distribution.

Note:
From C:\msys\1.0\doc\msys\README.rtf:
"If you wish to map a path with spaces you must use the DOS style name."
This also holds true for paths with spaces (a.k.a. 8dot3 file names) in script variables.
While the script /usr/local/bin/wp in Example 1 above works, the following script /usr/local/bin/wp_8dot3 will NOT work:
#!/bin/sh
# NON-WORKING SCRIPT!
# Running this script will fail with the following error:
#    /usr/local/bin/wp_8dot3: /c/Program\: No such file or directory
WP_EXE="/c/Program\ Files/Windows\ NT/Accessories/wordpad.exe"
$WP_EXE $@

Here is how to find the path manually:
#!/bin/sh
# CD C:\
# DIR /X|FINDSTR PROG
# Displays:
# 19/11/2007  10:16    <DIR>          PROGRA~1     Program Files
# CD "Program Files"
# DIR /X|FINDSTR WIN
# Displays:
# 04/04/2005  19:06    <DIR>          WINDOW~4     Windows Journal Viewer
# 22/02/2006  21:45    <DIR>          WINDOW~2     Windows Media Player
# 04/04/2005  18:40    <DIR>          WINDOW~1     Windows NT
# CD "Windows NT"
# DIR /X|FINDSTR ACC
# Displays:
# 04/04/2005  19:08    <DIR>          ACCESS~1     Accessories
# CD Accessories
# DIR /X|FINDSTR wordpad
# Displays:
# 04/08/2004  06:00           214.528              wordpad.exe
WP_EXE="/c/PROGRA~1/WINDOW~1/ACCESS~1/wordpad.exe"
$WP_EXE $@

Finding the path manually may be a bit tedious.
You can download the script non8dot3, which converts 8dot3 paths to non-8dot3 ones.

Additional tools
As mentioned before, MSYS requires MinGW to be installed.
If you want other development tools than make, you should consider installing msysDTK, which basically includes autoconf, automake, libtool, autogen, openssl, openssh, cvs, guile, and inetutils.
You may also install GDB for MinGW.

Read more
http://www.mingw.org/wiki/msys - Home Page
http://www.mingw.org/wiki/HOWTO - Documentation
http://allies.freezope.org/MsysMingw - Msys Mingw tutorial
Last modified: Wed Sep 7 12:29:48 EDT 2016