Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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 07:11 PM.
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:
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.