using curl/wget to call logout
Hi list, I'm trying to use curl to call the logout function of a logout button already working through browser. After successfully login the page lands at /home.jsp where the logout button is available. Pressing on that button the link redirects to login.jsp?message=logout Investigating the traffic after logout, shows the action preserve a cookie ~~~ JSESSIONID: E0EAC6A4CB37534FEF818A99D08BD499 Request URL: Login.jsp?message=logout Request Method: GET Status Code: 200 Referer: /home.jsp ~~~ already tried with curl -c my.cookie /home.jsp curl -X GET -c my.cookie /Login.jsp?message=logout but no success. How can I use curl/wget to logout through CLI ? thanks & regards, Bob
Re: using curl/wget to call logout
On Fri, Jul 15, 2016 at 05:40:40AM +, Bob wrote: > I'm trying to use curl to call the logout function of a logout button > already working through browser. snip > already tried with > > curl -c my.cookie /home.jsp > curl -X GET -c my.cookie /Login.jsp?message=logout > > but no success. How can I use curl/wget to logout through CLI ? It would be helpful if instead of 'no success' you provided precisely what did happen and what output/return code you got. The problem here, or really the behaviour you are asking questions about, is specific to whichever device you are trying to interact with, and is not really a wget question. Without knowing the device, there's little we can do to help you. You might need to set HTTP Auth headers for the wget request. If that were the case, the result of trying without would indicate that authentication was required. Cloning the session cookie from your browser won't work; the session management code in your device is designed to prevent you doing that. You will likely need to initiate a new session from a script, and use the cookie /that/ process sets for the request to press the poweroff button. You could try getting wget to set the referrer, you could also try asking wget to use the same User-Agent string as your browser. -- Jonathan Dowland ✎ j...@dow.land 🔗 jmtd.net Please do not CC me, I am subscribed to the list. signature.asc Description: Digital signature
Re: using curl/wget to call logout
>From Chromium's Development Tools (press F12) you can right-click a request in the Network tab and "Copy as cURL" Might help with handling cookies and other such things using curl -- Justin
Re: using curl/wget to call logout
On Friday 15 July 2016 10:28 AM, Jonathan Dowland wrote: On Fri, Jul 15, 2016 at 05:40:40AM +, Bob wrote: I'm trying to use curl to call the logout function of a logout button already working through browser. snip already tried with curl -c my.cookie /home.jsp curl -X GET -c my.cookie /Login.jsp?message=logout but no success. How can I use curl/wget to logout through CLI ? It would be helpful if instead of 'no success' you provided precisely what did happen and what output/return code you got. The problem here, or really the behaviour you are asking questions about, is specific to whichever device you are trying to interact with, and is not really a wget question. Without knowing the device, there's little we can do to help you. You might need to set HTTP Auth headers for the wget request. If that were the case, the result of trying without would indicate that authentication was required. Cloning the session cookie from your browser won't work; the session management code in your device is designed to prevent you doing that. You will likely need to initiate a new session from a script, and use the cookie /that/ process sets for the request to press the poweroff button. You could try getting wget to set the referrer, you could also try asking wget to use the same User-Agent string as your browser. Hi Jonathan, Thanks for your response. I need to login/out from a web-based form of ISP to enable/disable internet. I'm trying do the same from console with curl/wget. Now I have dig more and found following source code when logged in, wonder how to use it with curl/wget to call the logout function. ~~~ function logout(){ var out = confirm ('Do you really want to Logout ?') if(out){ document.forms["logoutForm"].submit(); } } function logoutbut(){ var out = confirm ('Do you really want to Logout ?') if(out){ document.forms["logoutbut"].submit(); } } id="logoutForm" style="margin-top: 0px;"> Welcome Logout value=""> ~ here is provided by the ISP regards, Bob