Hints and tips on windows

These are some helpful hints on various topics.

 

Installing Apache as Windows service

If you have not installed Apache webserver  on Windows via installer but from source or tarball then it will not be installed as service. To fix this press Start->Run and type in:
apache -i -n "Apache"

Mounting Windows shared folder in Linux

We have Windows resource under \\otherhost\share which we want to to see on the Linux machine as /mnt/winshare. Windows credentials are user/pass. So we use:

mkdir /mnt/winshare

mount -t smbfs -o username=user,password="pass" //otherhost/share /hmnt/winshare

or

mount -t cifs -o username=user,password="pass" //otherhost/share /hmnt/winshare

Capturing windows command output directly into clipboard

Windows command prompt is famous for plenty of disadvantages. One very annoying "feature" is that it breaks longer lines and if you want to copy them you need to manually glue them back. Here's one convenient way of capturing command output directly into clipboard: just type
| clip 

after the command. For example
netstat -an | clip

Now you can paste it in your favorite text editor.

Connecting to the console session on Windows 2003 Server

To connect to the console session on Windows Server via Remote Desktop, add /console:
mstsc /console
This is very useful in cases such as "terminal server has exceeded max number of allowed connections" - it gives you additional session to fix the mess.

/dev/null in Windows


Analogue for the /dev/null file on Windows is NUL. So the command
 
./my_prog 2>/dev/null
translates to
 
my_prog.exe 2>NUL

Perl inline replacement on Windows


Replacing some string in multiple files is one pretty feature of Perl. Just execute
 
perl -p -i -e 's/SEARCH/REPLACE/g' file.txt
and all SEARCH in file.txt transforms to REPLACE. On Windows there's a catch: this does not work with single quotes. So to get it working use
 
perl -p -i -e "s/SEARCH/REPLACE/g" file.txt