The Cassandra Project banner
by Winston Jenks <>

Problems with creating a script file for cross-platform compatibility:

  1. the default extension for an executable shell script is .ksh on the AW70.
  2. there is no default extension on the UNIX based systems.

The result is that foo tries to execute foo on a UNIX-based system and foo.ksh on an AW70.

Here is a simple workaround to keep the documentation identical for each system. Put all the shell scripting that does any work in a file that ends with .sh (for shell). Then make a file with the same name but with the .ksh extension for the AW70 that looks like this:

# AW70 wrapper for xxx $@

The $@ will expand to all the arguments that were passed to the wrapper. Then copy this file to the name, xxx, without any extension. This will be the file that runs by default under UNIX.

Of course, any idea is only as good as the utility that does the work, so here is an AWK file that will generate the <name>.ksh and <name> (no extension) files.

Just run "awk -f mkwrapper.awk *.sh" from the directory that has the .sh files in it.

#  Copyright (c) 2000 Winston Jenks. All Rights Reserved.             |
#                                                                     |
#                            |
#                                                                     |
#  This is free software; you can redistribute it and/or modify it    |
#  under the terms of the GNU General Public License as published by  |
#  the Free Software Foundation; either version 2 of the License, or  |
#  (at your option) any later version.                                |
#                                                                     |
#  This software is distributed in the hope that it will be useful,   |
#  but WITHOUT ANY WARRANTY; without even the implied warranty of     |
#  merchantability or fitness for a particular purpose. See the GNU   |
#  General Public License (    |
#  more details.                                                      |
#                                                                     |
#  To obtain the GNU General Public License, write to:                |
#                                                                     |
#      Free Software Foundation, Inc.                                 |
#      59 Temple Place - Suite 330                                    |
#      Boston, MA  02111-1307                                         |
#      USA                                                            |

# File: mkwrapper.awk
# Awk script to generate .ksh and (no extension) files
# This awk file will create a .ksh and a file with no extension for
# each .sh file passed to it. Run this with:
#     awk -f mkwrapper.awk *.sh
    # Set up the command location if we are running on AW70 and
    # have not set the path properly, otherwise leave it blank
    cmdpath = "/nutc/bin/"
    cmdpath = ""
    for (i=1; i < ARGC; i++) {
        print "Creating wrappers for " ARGV[i]
        fn = ARGV[i]
        sub(/\.sh/, "", fn)
        print "#!/bin/sh"          > fn ".ksh"
        print "# Wrapper for " fn >> fn ".ksh"
        print fn ".sh $@"         >> fn ".ksh"
        print "exit"              >> fn ".ksh"
        system(cmdpath "chmod +x " fn ".ksh")
        # Now make the file for UNIX, sure we could just do
        # system("cp " fn ".ksh " fn)
        # but that would be too easy.
        print "#!/bin/sh"          > fn
        print "# Wrapper for " fn >> fn
        print fn ".sh $@"         >> fn
        print "exit"              >> fn
        system(cmdpath "chmod +x " fn)

Copyright 2000 The Cassandra Project
web posted: 12 April 2000
last updated: 12 April 2000
Contact the webmaster for comments and/or questions.