Thursday Jul 30, 2009

Using Cygwin to manage script Virtual Box tasks

The Virtual Box GUI doesn't do everything one needs and so I have been experimenting with using cygwin, a free to use bash shell library. Having installed CYGWIN the first thing to do is add the Virtual Box program folder to the PATH, in my case,

    export PATH=/cygdrive/c/Program\\ Files/Sun/xVM\\ VirtualBox:${PATH}

I want this placed in the .bashrc so its always invoked, and thus need to test if is already in the path. I use this code,

    type -p VBoxManage.exe > /dev/null
    case $? in
    0)   # Its already there
         : ;;
    1)   # Add Path
         export PATH=/cygdrive/c/Program\\ Files/Sun/xVM\\ VirtualBox:${PATH} ;;
    esac

Now I need to associate a script file type with an execution program. I have tried to use the distributed batch file and binary and neiter of these work, so I have copied cygwin.bat to bash.bat and amended it so that it reads as follows

    @echo off

    :: Dave Levy (c) 2009         Is this GPL?
    :: bash.bat                   Version 1.0

    :: Wrapper to run \*sh scripts from windows explorer/desktop

    c:\\ksh\\bin\\bash --login %\*

I have deleted the -i flag from the bash line, I have made the bash program call absolute, %\* is the DOS batch command file syntax equivilant to $\* i.e. all the command line arguments, so the command line invokes bash.exe in login mode to force the execution of .bash_profile and .bashrc and appends all the other command line parameters including the script file name. :: is a neater comment delimiter than REM. I have associated my batch file with the file type .ksh as the open method using explorer.

Much of CYGWIN is distributed under the GPL and I am unclear if the batch file is included, If so, its GPL since I created the file by copying it.

keywords: howto invoke cygwin scripts from the windows desktop, write a dos batch file to invoke shell

tags:

Monday Feb 16, 2009

A bitty week

Last week was a pretty bitty week, dominated by the need to complete some mandatory, examined web training. I have recently completed similar training in Sun's Unified Storage Products which I found useful. This one is not so focused on technology and while useful in that I learned a couple of things, I really wonder if it was a good use of my time.

Prior to getting stuck in, I made some progress on my web estate including Laconica, planet and glassfish. I got a copy of mingle running on one of my Linux images but made no progress on installing Glassfish. I have taken advice and been recommended to use the Sun installer, but I am being stubborn and want to see if I can use the Ubuntu package installer.

Mind you I got fed up with bash & sh and installed the Korn Shell. I was able to use the package manager which is cool. I was expecting that some Linux religous view, or over zealous conformance with the various licenes would prohibit its inclusion, but it works fine. Since I shall only be using it for scripts, I don't need to write a global .kshrc and install it where ever it would need to be. What broke the Camel's back? I felt I needed $(). I had been lectured by Chris Gerhard about using this syntax a while ago because it supports nesting and finally came across a case where it was needed, or at least, coding speed and my skills meant that I decided to move over to it. (It does mean that anything I write may be harder for other Linux users to adopt.) So I'll write in ksh, and port to sh.

I ended the week on Sunday at the Chichester Smith and Western, where the atmosphere, decor and music are fun and the portions enormous.

tags:

About

DaveLevy

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today