LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-11-2010, 05:40 PM   #1
williebens
Member
 
Registered: Jan 2008
Posts: 88

Rep: Reputation: 16
curl and wget http post


Hello All:

I would like to find out how I would use both curl and wget to sent an http post to get the hostnames of a few servers. I know am not even given any work of anything I have done, but the reason is that I am really lost, and I do not even know how to start it.

Thanks.
 
Old 10-11-2010, 05:55 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I don't mean to sound like a jackass, but the first place you should always try are man pages whether on the system or on the internet.

From man wget:
Quote:
--post-data=string
--post-file=file

Use POST as the method for all HTTP requests and send the specified data in the request body. --post-data sends string as data, whereas --post-file sends the contents of file. Other than that, they work in exactly the same way. In particular, they both expect content of the form "key1=value1&key2=value2", with percent-encoding for special characters; the only difference is that one expects its content as a command-line paramter and the other accepts its content from a file. In particular, --post-file is not for transmitting files as form attachments: those must appear as "key=value" data (with appropriate percent-coding) just like everything else. Wget does not currently support "multipart/form-data" for transmitting POST data; only "application/x-www-form-urlencoded". Only one of --post-data and --post-file should be specified.
 
Old 10-11-2010, 08:09 PM   #3
williebens
Member
 
Registered: Jan 2008
Posts: 88

Original Poster
Rep: Reputation: 16
Hello Dark_Helmet:

You do not sound like a jackass, not at all. You are trying to help. I had already read the document you are referring to, and did me no good. I googled wget and curl for me to get this done, but I really did not get anything of what I found. That is why I said in my original post that I am not even showing any work.

I know I have to do something like this:
wget --post-data="Hostnames", but after that, I am stuck. I also know I have to configure Apache to handle cgi, but that is something I can do. It is the other part about wget and curl that got me really lost.

Thanks for your response.
--Willie

Last edited by williebens; 10-11-2010 at 08:11 PM.
 
Old 10-11-2010, 11:42 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Ok, so what you want is an example.

It's very, very simple. The man page tells you how to format the string. You can get the variables from the cgi script your web server will be hosting.

For purposes of an example, pretend your cgi has two variables/keys named "computer" and "style". A wget command might look like:

Code:
wget --post-data="computer=hosts&style=list" http://www.example.com

Last edited by Dark_Helmet; 10-12-2010 at 12:42 AM. Reason: Forgot to include a web address in the sample command
 
Old 10-12-2010, 12:03 AM   #5
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
If the servers happen to be e-mail servers then it might be far easier to do with telnet to port 25. Just giving Yahoo.com as an example, it is not perfect if you get deferred but you can always go back. In this simplistic example there is no reply if the connection was deferred. So I give you the frame work for the code, more homework can be done from your part to tweak it as needed.

Code:
 for i in $(dig yahoo.com MX | grep -v ';' |grep A |awk '{print $5}') ; do echo "###" $i ; telnet $i 25 2>@1 |grep 220 ; done
### 67.195.168.31
### 74.6.136.65
220 mta1031.mail.sk1.yahoo.com ESMTP YSmtp service ready
### 206.190.54.127
### 209.191.88.254
220 mta1043.mail.mud.yahoo.com ESMTP YSmtp service ready
### 67.195.168.230
220 mta1042.mail.ac4.yahoo.com ESMTP YSmtp service ready
### 98.137.54.237
### 98.137.54.238
220 mta1023.mail.sp2.yahoo.com ESMTP YSmtp service ready
### 66.94.236.34
### 74.6.140.64
220 mta1172.mail.sk1.yahoo.com ESMTP YSmtp service ready
### 66.94.237.64
### 98.139.54.60
220 mta1225.mail.ac4.yahoo.com ESMTP YSmtp service ready
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wget/curl problems PLS HELP tommmmmm Linux - Software 0 08-19-2005 04:58 AM
wget/curl problems. redirection after post method tommmmmm Linux - Software 1 08-10-2005 11:36 AM
ProxyServer: how to ping,nslookup,wget,curl etc from client PC ~=gr3p=~ Linux - Networking 2 06-10-2005 08:16 AM
YOU for SUSE 9.1 - curl or wget? djc SUSE / openSUSE 1 02-15-2005 04:26 PM
Wget and cURL can't connect umberleigh Linux - Newbie 0 09-21-2004 06:59 PM


All times are GMT -5. The time now is 11:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration