Link to home
Start Free TrialLog in
Avatar of projects
projects

asked on

curl as a variable breaks the script

The following variable was being used in a bash script;

CURL="curl -o /dev/null -u "$USERNAME:$PASSWD" --connect-timeout 5 -X POST"

Then, in my script, I would use the following;

$CURL -F function=clean_reports $SERVER_URL/myapp.php

I found that curl wasn't sending anything to php until I removed the variable and turned each curl line into the following;

 curl -o /dev/null  -u "$USERNAME:$PASSWD" --connect-timeout 5 -X POST -F function=clean_reports $SERVER_URL/myapp.php

Why? And how can I use this variable to shorten my lines?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of projects
projects

ASKER

Should have caught that myself. Yes, the username and password were AFTER the variable.

Thanks for the help, all fixed now.