How to pass parameters transparently into a sub script

Hi,

I am trying to write a script like this:

#!/bin/ksh
#script name: msgflow

#The awk commands for Solaris and Linux are incompatible
if [[ $(uname) == "SunOS" ]]
then
msgflow-solaris $*
elif [[ $(uname) == "Linux" ]]
then
msgflow-linux $*
fi

This script is shared by a file system which is visible to both a Linux system and a Solaris system. The systax of msgflow-linux is

msgflow-linux [-k keyword ] filename

Now in the Linux system if I run

msgflow -k "Call-ID: 41235036591@10.170.10.109" my.log

it complains

Using keyword Call-ID:. File "41235036591@10.170.10.109" does NOT exist, aborted!

And I updated the script msgflow to

if [[ $(uname) == "SunOS" ]]
then
msgflow-solaris "$"
elif [[ $(uname) == "Linux" ]]
then
msgflow-linux "$
"
fi

(added double quotes to $*)

Then it complains

Using keyword Call-ID: 41235036591@10.170.10.109 my.log. File "" does NOT exist, aborted!

Apparently in both cases the "-k keyword" option and "my.log" parameter were not correctly passed to the subscript msgflow-linux.

Can anyone please advice whether there is an easy way to resolve this?

My initial thoughts are, with the $*, any option and parameter can be transparently passed to the sub script.

Any help will be appreciated.

man getopt

Can you please make it clearer?

You problem is that the argument parsing is not happening properly. The getopt / getopts command can be used to accept arguments in typical unix style and they will parse arguments corretly & flexibly.

Example