cmdline with printf+nc and curl - gopher-tutorials - The gopher tutorials proje… | |
git clone git://bitreich.org/gopher-tutorials/ git://enlrupgkhuxnvlhsf6lc3fziv5… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
commit f7ab9d87c22c7522af42fcd997468e20ded31152 | |
parent 2eb761ef9eb86c59f63f78a0504deee794bb4582 | |
Author: Solene Rapenne <[email protected]> | |
Date: Tue, 30 Jan 2018 20:11:47 +0100 | |
cmdline with printf+nc and curl | |
Diffstat: | |
A cmdline.txt | 44 +++++++++++++++++++++++++++++… | |
1 file changed, 44 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/cmdline.txt b/cmdline.txt | |
@@ -0,0 +1,44 @@ | |
+Dear reader, in this document we will see differents command line | |
+software which can be used to connect to a gopher server. | |
+ | |
+ | |
+Printf + netcat | |
+=============== | |
+ | |
+It's possible to write request "by hand" using printf to format the | |
+request string and then netcat to send it to the remote server. | |
+ | |
+A request of the file "/tutorials/cmdline.txt" will looks like this : | |
+ | |
+ printf "/tutorials/cmdline.txt" | nc somedomain.com 70 | |
+ | |
+You will get the server answer directly into your output. Be careful | |
+if you ask binary files, it will be displayed on your screen, this is | |
+not something a regular user want. If you want to download a binary | |
+file, you can redirect the output to a file using ">" or pipe it to | |
+another software (or using tee for both at the same time). | |
+ | |
+The following example will download a music file, save it on the | |
+filesystem and play it with mpv while downloading. | |
+ | |
+ printf "/some_music.ogg" | tee saved_music.ogg | mpv - | |
+ | |
+You may have seen that the data type is not part of the request | |
+string, this is because it is only useful for the client to decide how | |
+to handle the content. In the current case, the client is YOU, so if | |
+you ask a menu and you want to download a file which has been tagged | |
+with type "I" then you should use the right process to deal with an | |
+image file. | |
+ | |
+ | |
+Curl | |
+==== | |
+ | |
+It is possible to use curl to connect to a gopher server, most of its | |
+options are supported, like timeout or traffic shaping. You need to | |
+pass a full url with "gopher://" at the start to curl to tell it you | |
+want to request a gopher server. | |
+ | |
+By default, curl will output the server result to stdout. Explanations | |
+can be found in the previous section about this. | |
+ |