Monday, April 29, 2024
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 351  / 1 Year ago, thu, december 22, 2022, 8:30:50

What is the GET command in Ubuntu? When I was trying out telnet, I accidentally typed in GET / too slowly, and it timed out, and I accidentally pressed Enter, and it ran the command GET.


The output was:


HTML>
<HEAD>
<TITLE>Directory /</TITLE>
<BASE HREF="file:/">
</HEAD>
<BODY>
<H1>Directory listing of /</H1>
<UL>
<LI><A HREF="./">./</A>
<LI><A HREF="../">../</A>
<LI><A HREF="bin/">bin/</A>
<LI><A HREF="boot/">boot/</A>
<LI><A HREF="cdrom/">cdrom/</A>
<LI><A HREF="dev/">dev/</A>
<LI><A HREF="etc/">etc/</A>
<LI><A HREF="home/">home/</A>
<LI><A HREF="lib/">lib/</A>
<LI><A HREF="lib32/">lib32/</A>
<LI><A HREF="lib64/">lib64/</A>
<LI><A HREF="libx32/">libx32/</A>
<LI><A HREF="lost%2Bfound/">lost+found/</A>
<LI><A HREF="media/">media/</A>
<LI><A HREF="mnt/">mnt/</A>
<LI><A HREF="opt/">opt/</A>
<LI><A HREF="proc/">proc/</A>
<LI><A HREF="root/">root/</A>
<LI><A HREF="run/">run/</A>
<LI><A HREF="sbin/">sbin/</A>
<LI><A HREF="snap/">snap/</A>
<LI><A HREF="srv/">srv/</A>
<LI><A HREF="swapfile">swapfile</A>
<LI><A HREF="sys/">sys/</A>
<LI><A HREF="tmp/">tmp/</A>
<LI><A HREF="usr/">usr/</A>
<LI><A HREF="var/">var/</A>
</UL>
</BODY>
</HTML>

What is this command?


When I run GET / HTTP/1.1, it displays http://www.i5.com/calacom at the end of the page... What is that website?


Edit:


man GET says:


LWP-REQUEST(1p)                                     User Contributed Perl Documentation                                    LWP-REQUEST(1p)

NAME
lwp-request - Simple command line user agent

Seriously! I did not run the command inside telnet!


whereis GET shows GET: /usr/bin/GET /usr/share/man/man1/GET.1p.gz.


All GET commands were run on the terminal itself! Do not post answers talking about HTTP in telnet. I am not new to HTTP.


More From » command-line

 Answers
4

This was also new to me. However, doing some investigation I concluded to the following:


$ whereis GET
GET: /usr/bin/GET /usr/share/man/man1/GET.1p.gz

So, this is a "command" under /usr/bin.


$ file /usr/bin/GET ; ll /usr/bin/GET
/usr/bin/GET: symbolic link to lwp-request
lrwxrwxrwx 1 root root 11 Jan 11 21:01 /usr/bin/GET -> lwp-request*

It is a symbolic link for lwp-request under the same directory.


$ ll /usr/bin/ | grep lwp-request
lrwxrwxrwx 1 root root 11 Jan 11 21:01 GET -> lwp-request*
lrwxrwxrwx 1 root root 11 Jan 11 21:01 HEAD -> lwp-request*
lrwxrwxrwx 1 root root 11 Jan 11 21:01 POST -> lwp-request*
-rwxr-xr-x 1 root root 16200 Jan 11 21:01 lwp-request*

There are other "symbolic links" to the same executable.


$ file /usr/bin/lwp-request ; dpkg -S /usr/bin/lwp-request
/usr/bin/lwp-request: Perl script text executable
libwww-perl: /usr/bin/lwp-request

This is a Perl script coming with the libwww-perl package.


$ man GET

More information about the command will reveal that there is a -u option:



-u Print request method and absolute URL as requests are made.



So, if we try the command in the Question using the -u option:


$ GET -u / HTTP/1.1

it displays:


GET file:/
<HTML>
<HEAD>
<TITLE>Directory /</TITLE>
<BASE HREF="file:/">
</HEAD>
<BODY>
<H1>Directory listing of /</H1>
...
</BODY>
</HTML>
GET http://www.HTTP.com/1.1
<html><head><title>www.http.com</title></head><frameset BORDER='0' frameborder='0' framespacing='0' rows='100%,*'>
<frame name='target' src='http://www.i5.com/calacom'>
<noframes> <body BGCOLOR='#FFFFFF'>
This page requires that your browser supports frames.
<BR>You can access the page without frames with this <a href='http://www.i5.com/calacom'>link</A>.
</body></noframes></frameset></html>

We see that when the GET command is given two arguments, it tries to access two URLs:



  1. file:/

  2. http://www.HTTP.com/1.1


The first one is a listing of the local / directory. The second one is the (probably non-existent) "page" 1.1 of the web site http.com which contains a "frame" to display the page http://www.i5.com/calacom.


[#1433] Thursday, December 22, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alkeake

Total Points: 467
Total Questions: 94
Total Answers: 126

Location: Tajikistan
Member since Tue, Jun 15, 2021
3 Years ago
;