0

If i run this command in linux command line manually it works, and EDIT.3126026369 is not empty

curl "http://somesite.com/admin.php?mod=editnews&action=editnews&id=14058" -s -L -b cookie.ck -c cookie.ck > EDIT.3126026369

in bash:

curl \"$EDIT\" -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP

but in a bash script it generate an empty file. what am missing here?

2 Answers 2

1

Use the quotes when defining your $EDIT variable:

EDIT="http://somesite.com/admin.php?mod=editnews&action=editnews&id=14058"

Then lose the escaped quotes on the curl command:

curl $EDIT -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP

Seems to work fine for me this way, how about you?

Sign up to request clarification or add additional context in comments.

4 Comments

To clarify, if you enter those 2 commands I highlighted into a bash prompt it doesn't work ? (well, COOKIE and TEMP would need to be defined too I suppose... but you get where I'm going, trying to figure out how what you're doing is different than me...)
no if i run curl somesite.com/… -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP it's ignoring everything after the ampersand [1]+ Done curl somesite/admin.php?mod=editnews
if i run curl "somesite.com/…" -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP it works...
basically i need quotes for the ampersand in my link, but adding quotes in bash script doesn't work.
0

What's in your $EDIT variable, and do you need to quote it like that? If it's your URL, I would simply expect you to write

curl $EDIT ....

If you run your bash script with a -x option, it'll show you each line that it executes. That's a very useful debugging technique.

1 Comment

the url link...the first command is an actual output from echo "curl \"$EDIT\" -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP" and i added quote because it contains ampersand in the link

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.