Why are requried to use /dev/tcpwriting a command transcript to fileWhy are bash_completion scripts persistently in environment?Zenity refuses to work in backgroundWhy are UNIX shells like this and how can I work around it?Is there a tool that automatically inserts and updates a script header block for e.g. shell or Python scripts?Why Can't I Call Two Aliases With “;”?Why is this code not working?sed stripping comments inlineWhy are true and false so large?tput command doesn't work in if statement

Can humans ever directly see a few photons at a time? Can a human see a single photon?

Does the monk's Step of the Wind feature activate the benefit of the Mobile feat?

Is it illegal to withhold someone's passport and green card in California?

Encounter design and XP thresholds

Why does independence imply zero correlation?

How can lift be less than thrust that is less than weight?

King or Queen-Which piece is which?

Why tighten down in a criss-cross pattern?

Should the party get XP for a monster they never attacked?

What does it mean to not be able to take the derivative of a function multiple times?

Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?

Can I enter the UK for 24 hours from a Schengen area, holding an Indian passport?

Why is it easier to balance a non-moving bike standing up than sitting down?

What can I do with a research project that is my university’s intellectual property?

How many people are necessary to maintain modern civilisation?

Excluding a rectangular region from an image in FITS

LWC - Local Dev - How can I run the local server on HTTPS?

career in signal processing

Will generated tokens be progressively stronger when using Cathar's Crusade and Sorin, Grim Nemesis?

How to parse 「場合でも」

Is there any proof that high saturation and contrast makes a picture more appealing in social media?

Can Ogre clerics use Purify Food and Drink on humanoid characters?

Do I need a shock-proof watch for cycling?

Hit the Bulls Eye with T in the Center



Why are requried to use /dev/tcp


writing a command transcript to fileWhy are bash_completion scripts persistently in environment?Zenity refuses to work in backgroundWhy are UNIX shells like this and how can I work around it?Is there a tool that automatically inserts and updates a script header block for e.g. shell or Python scripts?Why Can't I Call Two Aliases With “;”?Why is this code not working?sed stripping comments inlineWhy are true and false so large?tput command doesn't work in if statement






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















When trying to call /dev/tcp/www.google.com/80, by typing



/dev/tcp/www.google.com/80


Bash says no such file or directory. When looking at other people's code online, they use syntax such as



 3<>/dev/tcp/www.google.com/80


I noticed that this works as well:



</dev/tcp/www.google.com/80



Why are these symbols required to call certain things in bash?










share|improve this question









New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

    – ctrl-alt-delor
    7 hours ago












  • /dev/tcp/www.google.com/80

    – john doe
    7 hours ago











  • I edited your question, to say what I thing you mean.

    – ctrl-alt-delor
    7 hours ago

















2















When trying to call /dev/tcp/www.google.com/80, by typing



/dev/tcp/www.google.com/80


Bash says no such file or directory. When looking at other people's code online, they use syntax such as



 3<>/dev/tcp/www.google.com/80


I noticed that this works as well:



</dev/tcp/www.google.com/80



Why are these symbols required to call certain things in bash?










share|improve this question









New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

    – ctrl-alt-delor
    7 hours ago












  • /dev/tcp/www.google.com/80

    – john doe
    7 hours ago











  • I edited your question, to say what I thing you mean.

    – ctrl-alt-delor
    7 hours ago













2












2








2








When trying to call /dev/tcp/www.google.com/80, by typing



/dev/tcp/www.google.com/80


Bash says no such file or directory. When looking at other people's code online, they use syntax such as



 3<>/dev/tcp/www.google.com/80


I noticed that this works as well:



</dev/tcp/www.google.com/80



Why are these symbols required to call certain things in bash?










share|improve this question









New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











When trying to call /dev/tcp/www.google.com/80, by typing



/dev/tcp/www.google.com/80


Bash says no such file or directory. When looking at other people's code online, they use syntax such as



 3<>/dev/tcp/www.google.com/80


I noticed that this works as well:



</dev/tcp/www.google.com/80



Why are these symbols required to call certain things in bash?







linux bash io-redirection devices






share|improve this question









New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 7 hours ago









ctrl-alt-delor

13.4k52964




13.4k52964






New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









john doejohn doe

234




234




New contributor



john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




john doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

    – ctrl-alt-delor
    7 hours ago












  • /dev/tcp/www.google.com/80

    – john doe
    7 hours ago











  • I edited your question, to say what I thing you mean.

    – ctrl-alt-delor
    7 hours ago

















  • What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

    – ctrl-alt-delor
    7 hours ago












  • /dev/tcp/www.google.com/80

    – john doe
    7 hours ago











  • I edited your question, to say what I thing you mean.

    – ctrl-alt-delor
    7 hours ago
















What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

– ctrl-alt-delor
7 hours ago






What do you mean by “call”? Please show us what you are doing, when you get the error. Are you trying to execute it? Even if the front page of google was executable code, I would not recommend it.

– ctrl-alt-delor
7 hours ago














/dev/tcp/www.google.com/80

– john doe
7 hours ago





/dev/tcp/www.google.com/80

– john doe
7 hours ago













I edited your question, to say what I thing you mean.

– ctrl-alt-delor
7 hours ago





I edited your question, to say what I thing you mean.

– ctrl-alt-delor
7 hours ago










2 Answers
2






active

oldest

votes


















7














Because that's a feature of the shell (of ksh, copied by bash), and the shell only.



/dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that case.



Note that it has to be spelled like that. cat < /dev/./tcp/... or ///dev/tcp/... won't work, and will attempt to open those files instead (which on most systems don't exist and you'll get an error).



When you do cat /dev/tcp/..., that doesn't work because cat doesn't implement that same special handling, it does a open("/dev/tcp/...") like for every file (except -), only the shell (ksh, bash only) does, and only for the target of redirections.



That cat - is another example of a file path handled specially. Instead of doing a open("-"), it reads directly from the file descriptor 0 (stdin). cat and many text utilities do that, the shell doesn't for its redirections. To read the content of the - file, you need cat ./-, or cat < - (or cat - < -). On systems that don't a have /dev/stdin, bash will however do something similar for redirections from that (virtual) file. GNU awk does the same for /dev/stdin, /dev/stdout, /dev/stderr even on systems that do have such files which can cause some surprises on systems like Linux where those files behave differently.



zsh also has TCP (and Unix domain stream) socket support, but that's done with a ztcp (and zsocket) builtins, so it's less limited than the ksh/bash approach. In particular, it can also act as a server which ksh/bash can't do. It's still much more limited than what you can do in a real programming language though.






share|improve this answer
































    0














    You seem to be confusing the ideas or reading a file and executing a command. The difference between data and instruction.



    Googles front page is not an executable program. And if it was, it would not be safe to run it.



    The redirection characters (including < and >), are used to direct data into a command.



    We could do cat < /dev/tcp/towel.blinkenlights.nl/23 However this won't work for /dev/tcp/www.google.com/80 as this port will not respond until we send GET / HTTP/1.1nn



    So try



    exec 3<>/dev/tcp/www.google.com/80
    echo -e >&3 "GET / HTTP/1.1nn"
    cat <&3 #this does not return (in good time), as the connection is not closed.
    exec 3>&-





    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      john doe is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f525653%2fwhy-are-or-requried-to-use-dev-tcp%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      7














      Because that's a feature of the shell (of ksh, copied by bash), and the shell only.



      /dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that case.



      Note that it has to be spelled like that. cat < /dev/./tcp/... or ///dev/tcp/... won't work, and will attempt to open those files instead (which on most systems don't exist and you'll get an error).



      When you do cat /dev/tcp/..., that doesn't work because cat doesn't implement that same special handling, it does a open("/dev/tcp/...") like for every file (except -), only the shell (ksh, bash only) does, and only for the target of redirections.



      That cat - is another example of a file path handled specially. Instead of doing a open("-"), it reads directly from the file descriptor 0 (stdin). cat and many text utilities do that, the shell doesn't for its redirections. To read the content of the - file, you need cat ./-, or cat < - (or cat - < -). On systems that don't a have /dev/stdin, bash will however do something similar for redirections from that (virtual) file. GNU awk does the same for /dev/stdin, /dev/stdout, /dev/stderr even on systems that do have such files which can cause some surprises on systems like Linux where those files behave differently.



      zsh also has TCP (and Unix domain stream) socket support, but that's done with a ztcp (and zsocket) builtins, so it's less limited than the ksh/bash approach. In particular, it can also act as a server which ksh/bash can't do. It's still much more limited than what you can do in a real programming language though.






      share|improve this answer





























        7














        Because that's a feature of the shell (of ksh, copied by bash), and the shell only.



        /dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that case.



        Note that it has to be spelled like that. cat < /dev/./tcp/... or ///dev/tcp/... won't work, and will attempt to open those files instead (which on most systems don't exist and you'll get an error).



        When you do cat /dev/tcp/..., that doesn't work because cat doesn't implement that same special handling, it does a open("/dev/tcp/...") like for every file (except -), only the shell (ksh, bash only) does, and only for the target of redirections.



        That cat - is another example of a file path handled specially. Instead of doing a open("-"), it reads directly from the file descriptor 0 (stdin). cat and many text utilities do that, the shell doesn't for its redirections. To read the content of the - file, you need cat ./-, or cat < - (or cat - < -). On systems that don't a have /dev/stdin, bash will however do something similar for redirections from that (virtual) file. GNU awk does the same for /dev/stdin, /dev/stdout, /dev/stderr even on systems that do have such files which can cause some surprises on systems like Linux where those files behave differently.



        zsh also has TCP (and Unix domain stream) socket support, but that's done with a ztcp (and zsocket) builtins, so it's less limited than the ksh/bash approach. In particular, it can also act as a server which ksh/bash can't do. It's still much more limited than what you can do in a real programming language though.






        share|improve this answer



























          7












          7








          7







          Because that's a feature of the shell (of ksh, copied by bash), and the shell only.



          /dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that case.



          Note that it has to be spelled like that. cat < /dev/./tcp/... or ///dev/tcp/... won't work, and will attempt to open those files instead (which on most systems don't exist and you'll get an error).



          When you do cat /dev/tcp/..., that doesn't work because cat doesn't implement that same special handling, it does a open("/dev/tcp/...") like for every file (except -), only the shell (ksh, bash only) does, and only for the target of redirections.



          That cat - is another example of a file path handled specially. Instead of doing a open("-"), it reads directly from the file descriptor 0 (stdin). cat and many text utilities do that, the shell doesn't for its redirections. To read the content of the - file, you need cat ./-, or cat < - (or cat - < -). On systems that don't a have /dev/stdin, bash will however do something similar for redirections from that (virtual) file. GNU awk does the same for /dev/stdin, /dev/stdout, /dev/stderr even on systems that do have such files which can cause some surprises on systems like Linux where those files behave differently.



          zsh also has TCP (and Unix domain stream) socket support, but that's done with a ztcp (and zsocket) builtins, so it's less limited than the ksh/bash approach. In particular, it can also act as a server which ksh/bash can't do. It's still much more limited than what you can do in a real programming language though.






          share|improve this answer















          Because that's a feature of the shell (of ksh, copied by bash), and the shell only.



          /dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that case.



          Note that it has to be spelled like that. cat < /dev/./tcp/... or ///dev/tcp/... won't work, and will attempt to open those files instead (which on most systems don't exist and you'll get an error).



          When you do cat /dev/tcp/..., that doesn't work because cat doesn't implement that same special handling, it does a open("/dev/tcp/...") like for every file (except -), only the shell (ksh, bash only) does, and only for the target of redirections.



          That cat - is another example of a file path handled specially. Instead of doing a open("-"), it reads directly from the file descriptor 0 (stdin). cat and many text utilities do that, the shell doesn't for its redirections. To read the content of the - file, you need cat ./-, or cat < - (or cat - < -). On systems that don't a have /dev/stdin, bash will however do something similar for redirections from that (virtual) file. GNU awk does the same for /dev/stdin, /dev/stdout, /dev/stderr even on systems that do have such files which can cause some surprises on systems like Linux where those files behave differently.



          zsh also has TCP (and Unix domain stream) socket support, but that's done with a ztcp (and zsocket) builtins, so it's less limited than the ksh/bash approach. In particular, it can also act as a server which ksh/bash can't do. It's still much more limited than what you can do in a real programming language though.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 7 hours ago

























          answered 8 hours ago









          Stéphane ChazelasStéphane Chazelas

          322k57620986




          322k57620986























              0














              You seem to be confusing the ideas or reading a file and executing a command. The difference between data and instruction.



              Googles front page is not an executable program. And if it was, it would not be safe to run it.



              The redirection characters (including < and >), are used to direct data into a command.



              We could do cat < /dev/tcp/towel.blinkenlights.nl/23 However this won't work for /dev/tcp/www.google.com/80 as this port will not respond until we send GET / HTTP/1.1nn



              So try



              exec 3<>/dev/tcp/www.google.com/80
              echo -e >&3 "GET / HTTP/1.1nn"
              cat <&3 #this does not return (in good time), as the connection is not closed.
              exec 3>&-





              share|improve this answer



























                0














                You seem to be confusing the ideas or reading a file and executing a command. The difference between data and instruction.



                Googles front page is not an executable program. And if it was, it would not be safe to run it.



                The redirection characters (including < and >), are used to direct data into a command.



                We could do cat < /dev/tcp/towel.blinkenlights.nl/23 However this won't work for /dev/tcp/www.google.com/80 as this port will not respond until we send GET / HTTP/1.1nn



                So try



                exec 3<>/dev/tcp/www.google.com/80
                echo -e >&3 "GET / HTTP/1.1nn"
                cat <&3 #this does not return (in good time), as the connection is not closed.
                exec 3>&-





                share|improve this answer

























                  0












                  0








                  0







                  You seem to be confusing the ideas or reading a file and executing a command. The difference between data and instruction.



                  Googles front page is not an executable program. And if it was, it would not be safe to run it.



                  The redirection characters (including < and >), are used to direct data into a command.



                  We could do cat < /dev/tcp/towel.blinkenlights.nl/23 However this won't work for /dev/tcp/www.google.com/80 as this port will not respond until we send GET / HTTP/1.1nn



                  So try



                  exec 3<>/dev/tcp/www.google.com/80
                  echo -e >&3 "GET / HTTP/1.1nn"
                  cat <&3 #this does not return (in good time), as the connection is not closed.
                  exec 3>&-





                  share|improve this answer













                  You seem to be confusing the ideas or reading a file and executing a command. The difference between data and instruction.



                  Googles front page is not an executable program. And if it was, it would not be safe to run it.



                  The redirection characters (including < and >), are used to direct data into a command.



                  We could do cat < /dev/tcp/towel.blinkenlights.nl/23 However this won't work for /dev/tcp/www.google.com/80 as this port will not respond until we send GET / HTTP/1.1nn



                  So try



                  exec 3<>/dev/tcp/www.google.com/80
                  echo -e >&3 "GET / HTTP/1.1nn"
                  cat <&3 #this does not return (in good time), as the connection is not closed.
                  exec 3>&-






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 7 hours ago









                  ctrl-alt-delorctrl-alt-delor

                  13.4k52964




                  13.4k52964




















                      john doe is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      john doe is a new contributor. Be nice, and check out our Code of Conduct.












                      john doe is a new contributor. Be nice, and check out our Code of Conduct.











                      john doe is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f525653%2fwhy-are-or-requried-to-use-dev-tcp%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                      The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                      19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу