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
Are all Ringwraiths called Nazgûl in LotR?
Should the party get XP for a monster they never attacked?
Story about a space war, and a human prisoner of war captured by alien enemy
Why does using different ArrayList constructors cause a different growth rate of the internal array?
Pythagorean trigonometry identity
Excluding a rectangular region from an image in FITS
Count All Possible Unique Combinations of Letters in a Word
How can lift be less than thrust that is less than weight?
I found a password with hashcat, but it doesn't work
Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?
Why does independence imply zero correlation?
What is "industrial ethernet"?
Music theory behind A chord in the key of G
Counterfeit checks were created for my account. How does this type of fraud work?
Has there been any indication at all that further negotiation between the UK and EU is possible?
Greeting with "Ho"
How to make clear to people I don't want to answer their "Where are you from?" question?
Is it possible to get a mortgage with a custom duration in the US?
Intuition for the role of diffeomorphisms
Why are < or > requried to use /dev/tcp
Primes and SemiPrimes in Binary
Causes of High CHTs
What is the meaning of "понаехать"?
Shooting someone's past self using special relativity
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;
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
New contributor
add a comment |
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
New contributor
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
add a comment |
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
New contributor
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
linux bash io-redirection devices
New contributor
New contributor
edited 7 hours ago
ctrl-alt-delor
13.4k52964
13.4k52964
New contributor
asked 8 hours ago
john doejohn doe
234
234
New contributor
New contributor
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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>&-
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
edited 7 hours ago
answered 8 hours ago
Stéphane ChazelasStéphane Chazelas
322k57620986
322k57620986
add a comment |
add a comment |
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>&-
add a comment |
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>&-
add a comment |
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>&-
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>&-
answered 7 hours ago
ctrl-alt-delorctrl-alt-delor
13.4k52964
13.4k52964
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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