On Fri, Nov 01, 2002 at 02:49:21PM -0500, Jeff Barriault wrote:
> I have a script that's not working and I think I know why, but I just don't
> know how to fix it.
>
> Basically I'm trying to extract the command line parameters. For example: -h
> hostname -n username -w 80 -x 0 -y 0 acct
>
> Only problem is the actual parameters are passed without a space. For
> examle: -hhostname -nusername -w80 -x0 -y0 acct
Check into the getopt program. It is designed to be used with shell
scripts for this very purpose.
There are code examples in the manpage: man 1 getopt.
good luck.
>
> Here is a script that works with the spaces:
>
> # retrieve the username and hostname from the paramaters
> while :
> do
> case "$1" in
> -n) Username="$2"
> shift ; shift
> ;;
> -h) Hostname="$2"
> shift ; shift
> ;;
> -*) shift
> ;;
> *) break
> esac
> done
>
> Anyone know what I need to do to modify it to work without the spaces?
>
> By the way, this is comming from a Samba printer share that redirects the
> output file into a script. If there is a setting somewhere in Samba to get
> it to add spaces to it's command line parameters that would probably fix it
> too.
>
> Thanks!
>
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:45:09 EDT