Jason Squires
Jason Squires

Reputation: 27

cURL: (6) Couldn't resolve host 'GET' BASH script

I am having a problem with my bash script. It is producing an error of

curl (6) couldn't resolve host

What have I done wrong?

The following is my bash script.

#!/bin/bash
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed

CookieFileName=cookies.txt

TEST="curl -k --cookie  $CookieFileName --cookie-jar $CookieFileName POST -F "passUID=xxx&passUCD=xxx" https://wp1.coned.com/retailaccess/default.asp"

echo $TEST

RESPONSE=`$TEST`
echo $RESPONSE

Upvotes: 0

Views: 4081

Answers (1)

Gilles Quénot
Gilles Quénot

Reputation: 185189

Try this instead :

#!/bin/bash
set -o igncr

CookieFileName='cookies.txt'

curl -k \
    --cookie "$CookieFileName" \
    --cookie-jar "$CookieFileName" \
    --data "passUID=xxx&passUCD=xxx" \
    "https://wp1.coned.com/retailaccess/default.asp" # POST request

If you need to load another page after that, simply chains cURL commands with the previous line :

curl -k \
    --cookie "$CookieFileName" \
    --cookie-jar "$CookieFileName" \
    "https://wp1.coned.com/retailaccess/another_page.asp" # GET request

Note

Command Substitution: The $(foo bar) causes the command 'foo' to be executed with the argument 'bar' and $(..) will be replaced by the output. See http://mywiki.wooledge.org/BashFAQ/002, http://mywiki.wooledge.org/CommandSubstitution, and http://mywiki.wooledge.org/BashFAQ/082

Upvotes: 2

Related Questions