Random parameters passing in FTP script

Hi

I have a question.

In the FTP script if we are passing all the required value like Hostname, username, password, Action(put or get), Filename, & mode(ascii or binary) through parameters then we have to pass these in the exact orders in which they are taken like if we defined Username=$2 then we have to pass this as the second parameter.

Now if the user is completely unaware of the parameters numbering & passes all the parameters randomly, is there a way to identify which value belongs to which parameters.

Thanks
Sourabh
TCS

Make your script accept options like Unix commands.

myftpscript.sh -h hostname -m mode -u user -p passwd -a action -U usage

Use getopts inside the script to assign the actual values. See this linkfor some pointers towards getopts.

Hi

Seems a fanstastic solution, hey can u suggest some more alternative in which the user just pass only the values without any option as user still have to be aware of -h for hostname etc.

Really appreciate ur previous reply and will use that

Thanks
Sourabh