System Downtime

December 21, 2008

Wget and Post Data

Filed under: Programming, Scripting — Tags: , , , , — Michael Pobega @ 4:41 PM

I had an idea for a script to automatically log me in to Advance Wars by Web and grab the number of games which it is my turn in, but Wget seems to have a lot of trouble with post-data and cookies while accessing pages. Currently, this is how my script looks:

#! /bin/sh
# Script for grabbing “Your Turn Games” from AWBW (
# Written and maintained by Michael Pobega
# Special thanks to the GNU Wget manpage for help with cookie sessions

wget –keep-session-cookies –save-cookies cookies.txt –post-data ‘username=pobega&password=PASSWORD’ –keep-session-cookies

wget –load-cookies cookies.txt

Every time I’d login to the page, the downloaded yourturn.php would complain that I was not logged in. I’m going to mess around with this script a little more and hopefully find the problem.

Edit: Nevermind, I found the problem. I guess I’m a bit blind, but it’s right in the wget(1) manpage:

If the server is using session cookies to track user authentication, the above will not work because –save-cookies will not save them (and neither will browsers) and the cookies.txt file will be empty. In that case use –keep-session-cookies along with –save-cookies to force saving of session cookies.



  1. Hello,

    It should be –keep-session-cookies

    Although I’m sure you know that, it’s just your page comes up for a search, and it’d be useful to fix your post.

    I won’t be offended if you delete my comment.



    Comment by Chris Hawes — January 26, 2009 @ 7:17 AM

  2. I actually edited that a month or so ago, but forgot to include it in the initial command. Thanks for noticing.

    Comment by Michael Pobega — January 26, 2009 @ 7:47 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: