0

I have a bash script with the following content:

#!/bin/bash
cap=$1
assist=$2
host=$3

wget "http://$host:8080/MyApp/getNumberFromCap?cap=$cap&assist=$assist" -O - -o /dev/null

but when I run this script it does not make any call to the URL indicated. It seems like it's not resolving the variables put in it, in fact, if I replace the variables with a static content it works like a charm.

Where am I doing wrong?

2
  • 1
    Just escape the ampersand --> \&. Also, try doing echo "http://..." and see what is really printed. Then, replace with wget. Commented Jun 12, 2015 at 9:04
  • Works for me.. Are you sure the variables are filled with the correct values? Commented Jun 12, 2015 at 9:04

2 Answers 2

4

Escaping the & solved the issue:

wget "http://$host:8080/MyApp/getNumberFromCap?cap=$cap\&assist=$assist" -O - -o /dev/null
                                                       ^
Sign up to request clarification or add additional context in comments.

1 Comment

That's it! Thanks! In my case, a $ needed to be escaped.
0

I had to escape the equal sign too:

wget http://${HOST_IP}/my-bin/myscript?MAILADRESSEN\\="${MAILADRESSEN}"\\&SUBJECT\\="${SUBJECT}"

1 Comment

Please format the code properly when using code in your answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.