I need to triggeer a bash passing parameter with a format [ variable_name="value" ] like this:
./test.sh ip='164.130.21.98' hostname='whatever' pwd='/test' ftpcmd='CWD debug' user='stefano'
On test.sh script I want to assign to any variable the relevant value:
#!/bin/bash
eval `echo "$@"`
echo $ftpcmd
But I get a prova: command not found
error.
I cannot understand what's wrong on my ftpcmd='CWD debug'
parameter neither how I should write it instead.
If I try to replace eval with declare then the $ftpcmd
is set only to CWD
instead of CWD debug
as I'm expecting.
getopts
(bash built-in, short single-letter options only) or/usr/bin/getopt
(from util-linux, supports both short and --long options) – cas Oct 02 '15 at 10:39