Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using curl/wget to call logout

78 views
Skip to first unread message

Bob

unread,
Jul 15, 2016, 1:50:04 AM7/15/16
to
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 <link>/home.jsp where the logout button is available. Pressing
on that button the link redirects to <link>login.jsp?message=logout

Investigating the traffic after logout, shows the action preserve a cookie

~~~

JSESSIONID: E0EAC6A4CB37534FEF818A99D08BD499

Request URL: <link>Login.jsp?message=logout
Request Method: GET
Status Code: 200

Referer: <login>/home.jsp

~~~

already tried with

curl -c my.cookie <link>/home.jsp
curl -X GET -c my.cookie <link>/Login.jsp?message=logout

but no success. How can I use curl/wget to logout through CLI ?

thanks & regards,
Bob

Jonathan Dowland

unread,
Jul 15, 2016, 6:30:04 AM7/15/16
to
On Fri, Jul 15, 2016 at 05:40:40AM +0000, 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 <link>/home.jsp
> curl -X GET -c my.cookie <link>/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

Justin Steven

unread,
Jul 15, 2016, 7:40:04 AM7/15/16
to
>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

Bob

unread,
Jul 15, 2016, 3:00:03 PM7/15/16
to
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();
}
}
~~~~

<form action="logoutUI.do" method="get" name="logoutForm"
id="logoutForm" style="margin-top: 0px;">
Welcome<b> <USERNAME> </b> &nbsp;
&nbsp; <a href="javascript:logout();" style="background:
url(&quot;logout.GIF&quot;) no-repeat;" onmouseover="return
showStatus('text');">&nbsp;<u>Logout</u>&nbsp;</a>
<input type="hidden" id="SeUserName" name="SeUserName"
value="<USERNAME>"></form>
~~~~~

here <USERNAME> is provided by the ISP

regards,
Bob
0 new messages