Posting message in a forum using wget

Discussion in 'Command Line' started by AdnanAli, Feb 14, 2014.

  1. AdnanAli

    AdnanAli New Member

    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Hi

    This may sound a bit weird but I wanted to test wget to post message to a forum :). Here is what I would like to do:

    1- I am logged in a forum and backed up cookies in a text file.
    2- The message reply to be posted to a thread is also saved in a text file.


    Using above information how do I use wget to post a reply message to a thread topic?

    Thanks in advance for your help!
    DevynCJohnson likes this.
  2. arochester

    arochester Well-Known Member

    Messages:
    853
    Likes Received:
    274
    Trophy Points:
    63
    Strangely I don't think this is possible Wget is about downloading, not uploading. W-get. It's about getting.

    ...unless I can be shown to be wrong...
    DevynCJohnson likes this.
  3. AdnanAli

    AdnanAli New Member

    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Hello arochester

    Yes, wget is to get something from a server. But doesn't it now have --post-data and --post-file options to post data to the server? I am not sure about it, but think this could be done. If you can just go through the man page and confirm it?

    Or else, what do you think, can curl be used for this. If yes, how?

    Thank you for your reply.
  4. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,268
    Likes Received:
    431
    Trophy Points:
    83
    Code:
    Wget - The non-interactive network downloader.
    Even if it could be used, probably not the best choice. It is designed for downloads not uploads.

    Code:
    curl  is  a  tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP,
          LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP).  The command is designed to work without user interaction.
    
    Curl would be better yes
    DevynCJohnson likes this.
  5. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    That's a very interesting idea. I'll be interested to see if anyone presents a solution.

    But I'm sure that forum administrators across the globe cringe at the idea. You and I would use the capability responsibly, but there are hateful people who would write scripts to blast out millions of junk messages just so they can get URLs posted. They wouldn't care if they degrade sites to useless that many find valuable, as long as they get what they want at the moment.

    Never-the-less, I wonder if cadaver is what you're looking for. It's a command-line WebDAV client. From the man page, "cadaver supports file upload, download, ... cadaver supports automatically logging in to servers requiring authentication ..."

    I installed it years ago for some other purpose, but have never used it.
  6. MikeyD

    MikeyD Active Member

    Messages:
    232
    Likes Received:
    112
    Trophy Points:
    43
    It depends on how the forum manages posts. In more primitive setups where a simple form is filled out and submitted via GET or POST it wouldn't be too hard to issue a command in curl similar to:

    Code:
    curl -F "<name of form box>=<your message>" -u <username:password> <url of form action tag>
    In this form, and more sophisticated forums usually additional check are made, like @KenJackson mentions, mostly to keep out spammers and scripters looking to spam forums. I know in the case of this message board the text box is passed into an iframe which makes it harder to reference the text box's value to pass in parameters.

    I tried on this forum a little bit using the "message_html" textarea, which it looks like is used to save message drafts prior to submitting, but I couldn't get past a curl 26 error "failed creating formpost data" and had to get back to actual work at work :D. That might be a good place to start though. It seems like it should be possible but may require more time delving deeper into the curl man page than I was willing to devote.

Share This Page