5

I want to write a bash script that will notify me about changes on a trac wiki timeline. Unfortunately I can't "login" (it needs cookie for next logins).

wget http://someserver.com/trac/xxx/login \
--save-cookies=cookies --keep-session-cookies

wget http://someserver.com/trac/xxx/login \
--load-cookies=cookies \ 
--save-cookies=cookies.new --keep-session-cookies\
--post-data=user=viroos&password=myPassword

I get:

Error 400: Bad Request

I also tried --user --password options:

wget --no-check-certificate --user viroos --password myPassword\ 
https://someserver.com/trac/xxx/timeline?ticket=on&changeset=on&milestone=on&wiki=on&blog=on&max=50&daysback=90&format=rss

But this downloads only the login page.

What am I doing wrong?

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
Maciek Sawicki
  • 760
  • 1
  • 8
  • 21

2 Answers2

4

I think you are very close to the solution. This should work depending on your configuration:

wget --no-check-certificate --user viroos --password myPassword \
     --save-cookies=cookies --keep-session-cookies \
     https://someserver.com/trac/xxx/login

wget --no-check-certificate --load-cookies=cookies \
     https://someserver.com/trac/xxx/timeline?ticket=on&changeset=on&milestone=on&wiki=on&blog=on&max=50&daysback=90&format=rss

First call does the authorization on /login url and saves the auth cookie. The second call should get what you want.

This will work if you have basic autohrization enabled on ..../trac/login url.

silk
  • 918
  • 5
  • 13
1

The --user/--password flags in wget, for http URLs, cover HTTP basic authentication. Trac has its own login mechanism, so these flags won't work in this case.

There is a way to do what you want, (although I'm not sure wget is capable of doing it), but before spending time on that direction, did you consider using the TRAC timeline RSS feed?

The RSS feed will allow you to subscribe to the timeline changes, using your favorite RSS reader, and be notified of them. It will also give you a standard XML file for easy parsing, so you'll be able to do what you want with the data.

Tom Feiner
  • 16,758
  • 8
  • 29
  • 24
  • I now about rss time line, in fact I'm trying fetch it (at the end of url I have 50&daysback=90&format=rss). So I will parse XML. I'm doing this because I checking email often then rss reader and because trac authentication doesn't works with google reader so it's little. – Maciek Sawicki Nov 06 '09 at 17:20