&1" is unnecessary because I don't need to know the errors of the simple commands I was goin" name="description" /> &1" is unnecessary because I don't need to know the errors of the simple commands I was goin" />
49115

Unexpected redirect result with 2>&1 and command prompt

Question:

I was playing around with nc and since the -e command is gone, it recommended

cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f

I thought that the "2>&1" is unnecessary because I don't need to know the errors of the simple commands I was going to run like "whoami", "ls", etc. so my command instead is

cat /tmp/f | /bin/sh -i | nc -l 127.0.0.1 1234 > /tmp/f

But then, I don't get "clean" results. This is what I get

SERVER:

Listening on [0.0.0.0] (family 0, port 1234) $ $

Client:

nc localhost 1234 ls testfile whoami user1

Basically, I don't see the $ in my client terminal. When I do the command with the 2>&1, I get what I expected

SERVER:

Listening on [0.0.0.0] (family 0, port 1234)

Client:

nc localhost 1234 $ ls testfile $ whoami user1

I know that 2>&1 means redirect stderr to stdout so in this case, how is the command prompt "$" part of the stderr? Shouldn't it be part of stdin?

Answer1:

The shell uses the standard error stream for prompts, and also for menus created by select, and <em>any other text that is meant for interacting with the user</em>.

Recommend

  • c++ fork, without wait, defuncts execl
  • How do I initialize a struct field which is a mutable reference to an Option?
  • How to put a min-height in a relative class css ?
  • PHP system() and exec() functions not working with temp files
  • Write JSON data from front-end to back-end in nodejs
  • Understanding how to construct GHC.Generics Rep's and convert back to values
  • Why don't we register broadcast receiver for BOOT_COMPLETED events
  • CSS Local Font not showing up
  • Combinatios in List of LIsts Prolog
  • Fade Background but NOT Text
  • os.system not working, but typing the same thing into the command prompt works
  • Importing CSS is ending up with an error
  • Extract text from “” HTML tag
  • Docker container for google cloudML on compute engine - authenticating for mounting bucket
  • Is it possible to disable esc/F11 key during full screen mode of webpage, programmatically?
  • How do `pass` and `listen` work in WriterT?
  • How to use arithmetic operators with SAS macro variables [duplicate]
  • Netlink sockets and libnl - nl_recvmsgs_default returning -16 (EBUSY)
  • Recreate the Oracle DUAL table
  • How dotnet build chooses the output name
  • How to resolve this packager error on react native Android
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • OSX - always hide certain files
  • Installing PHP 7 on digitalocean
  • Problems installing Yesod for Haskell
  • How to revert to previous XCode version?
  • Not able to aggregate on nested fields in elasticsearch
  • Unable to install Git-core+svn by MacPorts
  • Stop Bash Script if Hive Fails
  • Django simple Captcha “No module named fields” error
  • How to Cache Real-time Data?
  • Mysterious problem with floating point in LISP - time axis generation
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Could not find rake using whenever rails
  • Where to put my custom functions in Wordpress?
  • SVN: Merging two branches together
  • Numpy divide by zero. Why?
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?