[Linux] Shell requests a web page

File descriptor

  • 0: standard input
  • 1: standard output
  • 2: error output

For example

1 exec 8<> /dev/tcp/www.baidu.com/80
2 echo -e "GET / HTTP/1.0\n" 1>& 8
3 cat 0<& 8
4 exec 8<& -
  • Create a new file descriptor 8
  • <>: Sending a request, and receiving response data
  • 1 kernel will perform after establishing a connection with Baidu socket
  • -e: Recognition \ n linefeed
  • GET: request method
  • /: Request Home
  • Sends a request to the kernel data after performing two Baidu, Baidu response descriptor is present in the 8
  • 3 performing a read response information
  • 4 Close the file execution

reference

linux redirection, exec achieve access Baidu home page

https://blog.csdn.net/weixin_43294560/article/details/102943327

A linux standard input output standard issue

https://lists.ubuntu.com/archives/ubuntu-zh/2012-June/012147.html

On Eight shell I / O redirection

https://blog.csdn.net/taiyang1987912/article/details/39401265

Guess you like

Origin www.cnblogs.com/cxc1357/p/12601099.html