Alec the Geek

Reflections on software and related things from an older geek

  • Twitter Ramplings

  • My Bookmarks

  • RSS Alec’s GitHub

    • An error has occurred; the feed is probably down. Try again later.

Archive for the ‘Windows’ Category

Handy hack: Make changes to the Cygwin mount prefix permanent

Posted by Alec The Geek on 13 January 2010

If you’re like me then the one of the first things you do after installing Cygwin is to issue the command mount -c / so that mounts appear directly under / instead of /cygdrive. However the recent upgrade to Cygwin DLL means that this change is no longer persistent. In order to make it permanent you need to edit the file /etc/fstab and add a line

none /  cygdrive binary,posix=0,user 0 0

Further details on the Cygwin site

Posted in Cygwin | 5 Comments »

Top Tip: Windows Perl CPAN slows to crawl using network drives

Posted by Alec The Geek on 8 January 2010

I noticed this when using Cygwin Perl, however I suspect the issue exists with any Perl distro on Windows.

The problem occurred when I had set the HOME environment variable to point to a network share. When I ran the CPAN utility it placed all the CPAN files on the network. As a result some modules would not install (I have no idea why) and it ran very very slowly.

The solution I adopted was to to move my home directory to the local PC drive which then made CPAN use the local drive as well.  Changing  cpan_home in  /usr/lib/perl5/5.10/CPAN/Config.pm would probably have been simpler, but I was happy to use the local disk for everything.

YMMV

Posted in Cygwin, Perl | Comments Off

Handy Hack: Make Vim the default editor for all text files

Posted by Alec The Geek on 7 January 2010

I just added the following tip to the Vim Tips wiki

To make Vim the editor for all text file types, as defined by MS Windows, try from the Windows command prompt:

ftype txtfile="C:\Program Files\Vim\vim72\gvim.exe" --remote-tab-silent "%1"

Posted in Windows | Comments Off

Handy Hack: Scripts to run Saxon XSLT processor

Posted by Alec The Geek on 5 January 2010

To save people having to reinvent the wheel here are a) a Windows batch file and b) Cygwin shell script to run the Saxon XSLT processor

@echo off

rem Run Saxon

c:\Progra~1\java\jre6\bin\java.exe -jar c:\Progra~1\Saxon9.2\saxon9he.jar %*
#!/bin/sh

# Run Saxon

/Progra~1/java/jre6/bin/java.exe -jar c:\\Progra~1\\Saxon9.2\\saxon9he.jar "$@"
echo

On UNIX or Linux

#!/bin/sh

# Run Saxon

/usr/bin/java -jar /usr/local/saxonhe/saxon9he.jar "$@"

You’ll obvioulsy need to modify the paths to suite the locations where you have things installed

Posted in Cygwin, Windows | Comments Off

Handy Hack:Improving Laptop Security

Posted by Alec The Geek on 31 December 2009

I have always liked having my laptop BIOS boot password on. i.e.  you can’t even boot from a CD unless you have first supplied credentials. However I’ve always been too lazy in the past to login ‘twice’, once to the BIOS and then to the operating system (OS) as a user. I’ve got around that as follows:

  1. Make sure that your screen saver is password protected and enabled
  2. Make sure your OS requires a password after resume
  3. Enable automatic user login.

Now you have to supply credentials every time you want to renew access to the machine, but you only have to supply credentials once on boot.

  • This is only useful if the machine is used exclusively  by you
  • You can either use ‘sudo‘ (Linux and OS/X) and ‘runas‘ (MS Windows) or logout/login to run programs as another user.

Posted in LinkedIn, Linux, Mac, Windows, Work Practices | 3 Comments »

Easy Introduction to Git

Posted by Alec The Geek on 4 September 2009

I’ve just had an article published by Sitepoint that aims to introduce Git to people who may not have programming experience and are more comfortable using a GUI rather the command Line. “Git: Your New Best Friend

Posted in Cygwin, Git, Open Source Software, Software Development, Web, Windows, Work Practices | Comments Off

Top Tip: Upgrade Git on Cygwin

Posted by Alec The Geek on 21 January 2009

The current version of git installed with Cygwin (1.5.x) has at least one annoying bug so it’s worth building  the latest version (NB I have almost all of Cygwin installed – you may need to install additional development tools and libs):

  1. Download and unpack the source code. Pointer here
  2. Run ‘./configure –prefix=/usr/local’
  3. Run ‘make test’
  4. Ignore errors relating to not detecting unwritable repos
  5. run ‘make install’
  6. run ‘hash -r’
  7. Make sure it’s installed with ‘type git’ and ‘git –version’

Update March/09 — I found more detailed instructions

Posted in Cygwin, Git, LinkedIn, Open Source Software, Software Development | 2 Comments »

Handy Hack: Run vim for Windows under Cygwin

Posted by Alec The Geek on 9 October 2008

UPDATED 30/Jan/09. With apologies for any confusion, previous example was completely wrong

For reasons I cant quite remember running the Windows gvim.exe binary directly from bash can lead to problems parsing path names. So I created an function as follows:

function gvim() { (
unset a
for i in "$@"; do
    case $i in
        -*)a=" $i $a";;
         *) if [[ -f $i ]] ; then
  a=" $a $(cygpath --absolute --dos "$i" )"
     else
  touch "$i" &&
  a=" $a $(cygpath --absolute "$i" )" &&
  rm -f "$i"|| echo "failed"
     fi
    esac
done
/progra~1/vim/vim72/gvim.exe $a&)}

Posted in Cygwin, Work Practices | Comments Off

All you developers will belong to us

Posted by Alec The Geek on 5 August 2008

Linux.com :: Why Microsoft cozied up to open source at OSCON

The company [Microsoft] wants to lure those developers back. Its open source play is aimed squarely at them, and at independent software vendors (ISV). They mean potential sales, and Microsoft has embraced the open source development model in order to tempt them away from the open source platform and over to the Windows platform.

A fairly insightful article on why MS turned up at PDX for OSCON last month. Given the huge market developers could have for any applications they develop using the MS ‘Open Source’ model this has to something that is taken seriously. The pleasing thing is that MS now sees OSS as such a threat — however now that the communities have Redmond’s attention it is going to be a tough battle for mind share.

Let’s keep doing what we do and stay frosty.

Posted in Business, Open Source Software, Personal Opinion, Windows | Comments Off

Top Tip: Installing Cygwin on Windows

Posted by Alec The Geek on 1 August 2008

If you are like me, a *nix user (sometimes) trapped in MS Windows land, then you’ll come to depend on the Cygwin utilities. Their use is pretty straight forward, but you can make life a little bit easier for yourself:

  • When installing Cygwin select the option for default UNIX / binary style line endings for files. When selecting DOS style text files I’ve had subsequent problems with Perl CPAN modules failing unit tests and bash failing to process login scripts
  • After the install issue a mount -c / command, this means that you can access drives without using the /cygdrive mount point (i.e. /c/Program\ Files instead of /cygdrive/c/Program\ Files)
  • NB This is not recommended practice, but for years I have been installing cygwin into the root of my C: drive, apparently without ill effects, and it does make life slightly easier. However you will need to modify startxwin.bat (and startxdmcp.bat if used) and make sure that the environment variable CYGWIN_ROOT is defined as an empty string.
  • Create a shortcut to invoke bash, I use “C:\bin\run.exe C:\bin\rxvt.exe -sl 2500 -fg lightblue -geometry 80x25 -bg midnightblue -sbt 10 -title bash -e /bin/xhere /bin/bash.exe %HOME%” (noting of course that I install into the root of the C: drive). You can also use chere to install a ‘Open Bash here’ option in Windows Explorer

Anyone else have anything to pass on?

Posted in Cygwin, Windows, Work Practices | 8 Comments »

Top Tip: Cygwin Perl has problems running with UNC path names

Posted by Alec The Geek on 10 July 2008

When running Cygwin Perl using libraries that live on UNC paths (e.g. when running prove with the -l option) Perl will croak because it is unable to load the library. An example error message will look something like:

t/00.load.............Can't open perl script ""-I//server/sharename/work/mymodule/lib"": No such file or directory

The fix is to map the UNC path to a drive letter and use the Cygwin mount point (e.g. ‘/cygdrive/z/work/mymodule’) as the path instead.

The command is

net use z: '\\server\sharename'

Posted in Cygwin, Perl | Comments Off

How not to live by your own rules (or are you *really* listening Steve Ballmer?)

Posted by Alec The Geek on 23 June 2008

Bill Gates’ 4 golden rules at Microsoft – Jun. 20, 2008

Gates’ 4 golden rules

Fortune Magazine reports on Bill Gate’s supposed four core beliefs that Microsoft lives by, you can read them at the above link. However, as an outsider, I think there may be a little self delusion going on.

  1. Think of software as a utopian tool” — unfortunately it’s very hard to understand what this rule means in terms of the companies behaviour and sounds a lot like hand waving. Are MS telling themselves they need to keep looking for new markets? How does an employee use this rule to guide what they do?
  2. Let the engineers rule” — given some of the  buggy software has been shipped all too frequently by the Redmond giant  it often feels to me that it’s the accountants and product managers who actually make the decisions with little regard to the reality the engineers are facing. If that is not the case then the suggestion would be that the engineers more  focused on the value of their share options they should be, hence software going out the door before it’s ready.
  3. Institutionalize paranoia” — Given the pressure that MS has faced over the last few years from legislators, the Internet, Apple and Open Source software then this has to be a clarion call for survival, as it should be in any commercial organisation. File this under “Motherhood and Apple Pie”
  4. Invest for the long term” — makes good sense for any organsation that can afford it, but Sharepoint is still a piece of crap even after all that long term investment. Being cash rich helps of course, but the investment needs to be nimble; long term; and contantly reviewed. Does Microsoft meet those objectives?

Elsewhere Fortune reports that MS will ‘soon’ be starting a campaign to fight against the highly successful Apple Mac ads. However the Apple ads have been running for two years now — this is hardly the ‘agile’ business response of an alert, “paranoid’, organisation. Thirty years ago I suggested the fall of IBM and the idea was considered risible; well I believe, and have for some time, that the same thing is happening again. Just wait a little…

[Updated July 2008 after internal Oracle articles implied this was a less than professional piece. Many thanks]

Posted in Business, Personal Opinion, Windows | Comments Off

Take 2:What I add to Windows that helps make it better

Posted by Alec The Geek on 19 June 2008

(Updated 28/Aug/09 with Open Source Windows site)

Essentials to make Windows almost bareable « sinewalker

a list of what free software to install on top of Windows, and what adjustments to make, so that at least I don’t feel like I’m wearing a straight jacket

Some excellent ideas and suggestions from Sinewalker here and there are more at Open Source Windows. I posted my own list of Windows essentials back in 2002 and I’ve been thinking for some it’s time to tidy the list up a bit since the world has moved on, so here goes:

Software development related:

Desktop and Misc

Security

All of these tools are free of charge and many are Free software, which helps with the budget. However please consider a donation if it’s asked for and you can afford it.

In addition I change the default XP theme and use Windows 2000 as it takes up less screen space (or least it feels like it does) but use the ‘modern’ start menu.

Posted in Personal Opinion, Software Development, Windows, Work Practices | Comments Off

Handy Hack: How to configure the cpan utility to use Windows proxies

Posted by Alec The Geek on 29 May 2008

When using cpan.bat the following may be helpful. Please note that this is for a Windows corporate network infrastructure and was tested using both Strawberry and Cygwin Perl in the current network environment where I work. YMMV!

BEWARE THAT THIS APPROACH STORES YOUR LAN PASSWORD ON YOU LOCAL HARD DISK. THIS IS INSECURE!

Step 1: Information Gathering

  1. Discover the address of your proxy: If using a PAC file (look in IE Tools->Internet Options-> Connections -> LAN Settings and identify the setting ‘Use automatic configuration script’) then download the PAC file and open in a text editor. The default proxy address (e.g. proxy.corp) and port (e.g. 80) will probably be at the bottom of the PAC script. If you are not using a PAC script then the proxy address will be in the LAN Settings dialog.
  2. Know your domain name (e.g. corpdom) and lan ID (e.g. lanname)
  3. You will also need your lan password (e.g. secret)

Step 2: Configure CPAN

  1. From the command line ensure that you running the correct version of perl (perl –version)
  2. run the command cpan
  3. You may be asked some configuration questions — answer as best you can and take defaults if not sure
  4. At the CPAN Prompt type the following commands:
    1. o conf proxy_user corpdom\\lanname (NB Double slash required)
    2. o conf proxy_pass secret
    3. o conf ftp_proxy http://proxy.corp:80 (NB No trailling slash on URL)
    4. o conf http_proxy http://proxy.corp:80 (NB No trailling slash on URL)
  5. Now try and install something (e.g. i Bundle::Perl::Critic)

[Update: July 2008 -- tested on Strawberry and Cygwin Perl. See also]

Posted in Cygwin, Perl | Comments Off

Handy Hack: Can’t run perldoc on Cygwin

Posted by Alec The Geek on 28 May 2008

When running perldoc on certain Windows systems using Perl under Cygwin it is possible to get an error message

Error in tempfile() using ./XXXXXXXXXX: Parent directory (./) is not writable

This is more likely to happen if your system has been ‘hardned’ by a corporate IT department. The fix is as follows:

  1. Make sure $TMPDIR is defined and points to somewhere sensible (e.g. $TMP)
  2. Make sure you have read/write permissions (chmod 777 $TMPDIR)

Posted in Cygwin, Perl, Windows | Comments Off

Handy hack: Install CPAN modules by hand when there are multiple Perls

Posted by Alec The Geek on 21 May 2008

On Windows it’s very easy to end up with with multiple installtions of Perl (e.g. I have Strawberry Perl, Cygwin perl and Activestate Perl installed by Twiki).

If you download CPAN modules and then install them by hand things don’t always go where you think.

The (obvious) trick is to make sure you are running the correct Perl (and make tool) before you begin the install process. Let’s take Strawberry Perl as an example:

  1. Make sure the correct perl bin is first in the PATH
    set PATH=c:\strawberry\perl\bin;%PATH%
  2. Make sure the correct make program is first in the PATH
    set PATH=c:\strawberry\c\bin;%PATH%

You should then be able to run perl Makfile.PL, dmake, dmake test, dmake install. However if you have a problem then correct the environment and run dmake -u to force a rebuild. (If you are using something other than make program then you’ll need to find the correct option)

Posted in Perl, Windows | Comments Off

Putty — what a cool tool

Posted by Alec The Geek on 15 May 2008

Previously, like probably 80% of other users, I had only used Putty as a ssh enabled terminal emulator. However after my adventures with emacs I’ve come to realise what a great tool it is, including it’s support for comand line use.

If you are stuck using Windows without OpenSSH (e.g. not using Cygwin) then I recommend you get Putty.

 

Some of it’s features are:

  • Key generation and management (including import/export of OpenSSH keys)
  • A key caching utility (so you don’t have to keep typing the key passphrase)
  • command line ssh support vi plink
  • support for scp and sftp (pscp and psftp)

Every time I’ve used it it’s been rock solid and handled everything thrown at it (including things that OpenSSH had trouble with — although to be fair that was probably not OpenSSH’s fault)

Posted in Windows, Work Practices | Comments Off

emacs Tramp on Windows

Posted by Alec The Geek on 15 May 2008

Updated Oct/08

I am using emacs with the tramp extension to edit files on a remote server using ssh. I had to pull in various hacks to get it to work so I hope these notes might help others.

  1. Install Emacs for Windows and Cygwin with OpenSSH
  2. Upgrade emacs Tramp to the latest version. This is best done using Cygwin bash and Cygwin make (in particular ensure that –with-lispdir and –infodir options are set correctly when running configure).
    • Handy tip — leave the tramp build directory hanging around. When you next upgrade Emacs it’s just make install (providing you use same directory names)
  3. Ensure that the Cygwin bin directory is on the Windows system path
  4. At the Cygwin bash prompt test ssh connection to your host
  5. Generate public/private keys and upload to the host
  6. Test ssh again to see if public authentication works (it did not for me because it had been disabled by the UNIX admin)
  7. Configure emacs to use tramp
    (require 'tramp)
    ;;(setq tramp-debug-buffer t)
    ;;(setq tramp-verbose 10)
    (setq tramp-auto-save-directory "c:\\tmp")
    (setq tramp-default-method "plink")
  8. Start emacs and test connection (C-x C-f) using cygwin ssh/scp/sftp. If it works skip to step 14. I had issues so I continued with step 9
  9. Install the Putty program suite
  10. Test the connection using putty
  11. Ensure the Putty install directory is on the system PATH
  12. In emacs visit the host (C-x C-f) using the method ‘plink’. If that does not work you are on your own (but see troubleshooting below)
  13. If the public keys worked in ssh then import your OpenSSH keys into Putty
  14. Use emacs bookmarks to save your common host locations

Troubleshooting:

  1. Getting rid of the “Couldn’t find exit status of `test -e …” error message by deleting ~/emacs.d/tramp file. This clears cached settings as documented at http://www.nabble.com/Emacs-tramp-troubles-with-old-Sun-tt13607411.html.
  2. If Tramp and Emacs does not work for you try these alternatives:
    1. Vim has a netrw plugin
    2. Both FileZilla and WinSCP have options to edit a file from the remote file system which then invokes a local Windows editor of your choice.
    3. jEdit has an ftp plugin that supports sftp and bookmarks

YMMV

With many thanks to all the folks on the web who documented their experiences and Michael Albinus on the tramp-devl mailing list.

Posted in Cygwin, LinkedIn, Open Source Software, Security, Software Development, Windows, Work Practices | 1 Comment »

Windows Explorer ‘Open Bash Here’

Posted by Alec The Geek on 19 October 2006

Updated May 2008

As mentioned by Andrew below this is all too hard now that we have the chere utility. At the cygwin shell prompt try the following

chere -i -c -n -t rxvt -s bash -o "-sl 2500 -fg lightblue -geometry 80x25 -bg midnightblue -sbt 10 -title bash" -e "Open Bash shell here"

If you want a shortcut to run bash for your home directory try

C:\bin\run.exe C:\bin\rxvt.exe -sl 2500 -fg lightblue -geometry 80x25 -bg midnightblue -sbt 10 -title bash -e /bin/xhere /bin/bash.exe %HOME%

——————————————————————————-
For users of Cygwin on Windows who like the Open Command Window Here power toy

I took this hack and this hack and combined them to make the following hack. It works on both directories and drives in Windows Explorer, and creates a visually attractive login shell (at least I think so).

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\bash]

@="Open Bash Shell Here"

[HKEY_CLASSES_ROOT\Directory\shell\bash\command]

@="c:\\\\bin\\\\bash.exe --login -i -c 'cd \"`cygpath \"$*\"`\";exec rxvt -sr -sl 2500 -fg lightblue --geometry 80x25 -bg midnightblue -sb -e bash' bash %L"

[HKEY_CLASSES_ROOT\Drive\shell\bash]

@="Open Bash Shell Here"

[HKEY_CLASSES_ROOT\Drive\shell\bash\command]

@="c:\\\\bin\\\\bash.exe --login -i -c 'cd \"`cygpath \"$*\"`\";exec rxvt -sr -sl 2500 -fg lightblue --geometry 80x25 -bg midnightblue -sb -e bash' bash %L"

Posted in Cygwin, LinkedIn, Work Practices | 9 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 272 other followers

%d bloggers like this: