I am trying to write a BASH command that uses CURL to send a GET request to two different web pages, but uses the same connection. For me it is like sending a GET request to the login page for authentication on the server, and then the second request simulates an automatic redirect to the home page that would occur in a web browser (using the meta refresh tag). I need to link the requests because the contents of the home page (generated by the server) will be different for the guest user than the authenticated user.
I tried this command first based on the recommendation of the SOF message (suppose the $IP and $PORT variables were already defined with valid values):
curl -u user:pass ${IP}:${PORT}/login.php && curl ${IP}:${PORT}/index.php
However, I always get something like this happening between the end of the first GET and the beginning of the second:
* Connection #0 to host 10.0.3.153 left intact * Closing connection #0
So was the SOF post wrong? In any case, the execution of this command will successfully maintain a connection between two requests:
curl -u user:pass ${IP}:${PORT}/login.php ${IP}:${PORT}/index.php
However, I would prefer a solution closer to the first team than the last team. The main reason is to separate the output from the first page compared to the second page into two different output files. So I want to do something like:
curl page1.html > output1 && curl page2.html > output2
Of course, I need to reuse the same connection, because the contents of page2.html is up to me and makes a request to page1.html in the same HTTP session.
I am also open to solutions that use netcat or wget, BUT NOT PHP!
source share