PDA

View Full Version : factor submission script?



Frodo42
05-20-2004, 10:06 AM
I'm wondering if there is a simpler way to submit factors than having to open a browser and then go to www.seventeenorbust.com.

There must be some way to make a script in Linux that automaticly submits new factors to the text-field on the homepage and then presses the submit button.

I've been trying to google for at solution, but it's not easy to find the right words to google for. I've also been looking a bit on the man-pages of links and similar programs without much luck.

So if anyone's got an idea of which program I should use in the script it would be much appreciated.

Joe O
05-20-2004, 04:16 PM
I'd recommend doing it in PERL. That way it could easily be ported to Windows.

mklasson
05-23-2004, 04:11 AM
Give wget a try -- it's available for lots of platforms. Remember to submit info on the login page as well if you're not always logged in though.

You'll want to POST factor data to /sieve/sievePost.mhtml. The factor field is called "factors", but look in the file yourself.

Login info should be POSTed to /login/loginPost.mhtml if you need it, with something like:
postdata = "-login=true&-username=" + urlencode( cfg_username ) + "&-password=" + urlencode( cfg_password );

Frodo42
05-31-2004, 04:08 PM
I finally took a little time to read some man-pages

wget seem to be doing the job, thanks for the tip mKlasson :notworthy
the following command is basicly what does it:

wget --load-cookies cookies.txt --post-file=fact.txt http://www.seventeenorbust.com/sieve/sievePost.mhtm
The cookies.txt file is taken from the cookie created by the web-site when you log in.
wget creates a sievePost.mhtml(.* if one already exist) file in which one can see the results of the sumbission (this avoided by the --delete-after tag)
For this to work I add factors= to the start of my fact.txt file and remove the '+1' at the end of each line of fact.txt.
For some reason wget won't submit the '+', i guess it's something with the format of strings in UNIX, but I haven't figured out what it is yet.
Any help on this little problem would be appreciated, I guess one could just make a little workaround script that removed the '+1' part of each line, but I there must be another way ...

Anways my plan is to cron this job when I leave my computer for longer periods so that I don't need to worry about factors not being submitted in timely fashion.
I guess I should also should write a little script to sort out which factors have been submitted, but as long as it's only for factoring and one just remember to remove older factors from fact.txt I guess the server load won't be all to big when I only let cron do the job every 24 hours.

mklasson
05-31-2004, 05:27 PM
The problem is that + is used to encode a blankspace. %XY can be used to encode any ASCII character by giving the hexadecimal code -- %2B corresponds to a normal plus sign.

Frodo42
06-01-2004, 12:44 AM
well now I made my workaround using sed


sed {s/+/%2B/} fact.txt > submit.txt
wget --load-cookies cookies.txt --post-file=submit.txt http://www.seventeenorbust.com/sieve/sievePost.mhtml
rm submit.txt

It probably could be done in a nicer way, but it does the job.
Thanks for the help mklasson

hc_grove
06-01-2004, 04:21 AM
Based on this discussion I've now made the following shell-script which submits any new factors:



#! /bin/sh

rm submit.txt
/usr/sbin/logtail fact.txt > new_factors.txt
if [ -s new_factors.txt ]; then
(echo 'factors='; cat new_factors.txt) | sed -e 's/\+/%2B/' > submit.txt;
wget --load-cookies ~/17_or_bust/p-1/cookies.txt --post-file submit.txt http://www.seventeenorbust.com/sieve/sievePost.mhtml
fi
rm new_factors.txt


It uses a little (often overlooked) utility called logtail to get the new factors, and then it's basically what Frodo42 did, except that I've created a custom cookies.txt that only contains the cookie from www.seventeenorbust.com.

Frodo42
06-01-2004, 05:55 AM
This is working out just fine, thanks hc_grove.
btw. logtail is in gentoo contained in the e-build logsentry or can be found on http://www.fourmilab.ch/webtools/logtail/