Reputation: 11
I have a command that I want to put in a script but I'm having issues. The command is very picky and it looks like this:
command_to_run -H 'ip_address' -u 'user' -p 'passwd' --register naming_data "/location/of/backup/folder/" "[destination-location]"
I want to create an interactive bash script that asks the user for the ip_address, user, password, location of backup folder and a destination location. The problem I'm having is that I'm storing the user's input on variables (IP_ADD, USERNAME, etc) but when I pass it to the command like
$COMMAND -H '$IPADD' -u '$USERNAME' .....
but again my issues are in the single quotes, the "/" the "[]" ad passing the variables. Can anyone give me a hint and what I need to fix in order to have it working??
Upvotes: 0
Views: 150
Reputation: 110
Like Etan said, use double quotes:
command_to_run -H "$ip_address" -u "$user" -p "$passwd" ....
Upvotes: 1
Reputation: 157947
Use double quotes:
$COMMAND -H "$IPADD" -u "$USERNAME" ...
If you use single quotes in the shell, variables will not getting expanded meaning the literal $USERNAME
will being used for the username.
Upvotes: 0