Access a complete flow with CURL + bash shell

Hello Experts ,

I have an use case which needed your help . I have been using google for 2 days buy couldn`t succed , i believe i can get the help here.

Here is my use case to run on bash shell

  1. Access an URL -- in script , it will be mentioned as inputURL
  2. Once i accessed the URL on step 1 , it will be redirected to a login page - in script it will be called as LoginPageURL
  3. I will key in the creds with below syntax of curl - creds.txt has credentails saved
hitlogipage = curl --url $LoginPageURL  -K- <<< "--user $mydir/creds.txt"
  1. Once i accessed internally , it will get redirect to an .fcc page and then to URL2 .
  2. While it redirect to URL2 , it will have some cookie details in headers , which i need to capture and display-- It will be awked and saved on a variable called SessionCookie.
curl -I $hitloginpage

Can some one provide me some help ?

i couldn`t achieve step 4 and 5 .
and on step 3 , i keep getting "curl: (3) <url> malformed" . But when i give same with what is inside LoginPageURL , i am successfully redirecting to step 4.

Stupid question, but could you use the -c/--cookie-jar switch to save the cookies into a file?

Andrew

@andrew, I never worked on Java.. If you can give me a highlight I can Google and understand myself how I can take further...

java? I thought you were using bash.

Curl has an option, -c in its short form, --cookie-jar in its long form, to save cookies:

curl --cookie-jar my-cookies http://some.url.com

Can you not use that to save the cookies, and read the file for the cookies you are interested in?

The curl man page can be found here.

Andrew

I meant shell, by seeing jar thought your were referring to Java. Never mind..

I Gonna try this and keep you posted with result. But with your explanation seems it will work..

Do you have any suggestion on the url error I am getting when adding the url into a text file and using with - url option?

If your URL is in a file named inputURL, and you want the result stored in file pageText. You should use:

curl --cookie-jar my-cookies --url $(< inputURL) > pageText