i just wanted to make a little bash script to automatize some actions i do on my forum on a regular basis. I was perfectly able to reply to a post in my forum following this example:
Code: Select all
#!/bin/bash
LOGINURL="http://.../ucp.php?mode=login"
POSTURL="http://.../posting.php?mode=reply&f=xx&t=xx"
USERNAME="..."
PASSWORD="..."
#retrieve cookies
curl -s -d "username=$USERNAME" \
-d "password=$PASSWORD" \
-d "login=Login" $LOGINURL -c cookies.txt
#get necessary posting information
curl -s $POSTURL -b cookies.txt -o "post.html"
#yes - this could be improved
postid=$(grep 'topic_cur_post_id' post.html | cut -d'"' -f6)
lastclick=$(grep 'lastclick' post.html | cut -d'"' -f12)
creationtime=$(grep 'creation_time' post.html | cut -d'"' -f6)
formtoken=$(grep 'form_token' post.html | cut -d'"' -f6)
POST="whatever you want to post...."
#wait some seconds -- won't work without
echo "waiting 10 seconds..." && sleep 10
#post your message
curl --data-urlencode "message=$POST" \
-d "topic_cur_post_id=$postid" \
-d "lastclick=$lastclick" \
-d "creation_time=$creationtime" \
-d "form_token=$formtoken" \
-d "post=Submit" $POSTURL -b cookies.txt
#cleanup
rm cookies.txt
rm post.html
Code: Select all
lastclick=$(grep 'lastclick' post.html | cut -d'"' -f6)
creationtime=$(grep 'creation_time' post.html | cut -d'"' -f6)
formtoken=$(grep 'form_token' post.html | cut -d'"' -f6)
curl --data-urlencode "message=$POST" \
--data-urlencode "edit_reason=$EDIT_REASON" \
-d "lastclick=$lastclick" \
-d "creation_time=$creationtime" \
-d "form_token=$formtoken" \
-d "post=Submit" $EDITURL -b cookies.txt