Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

ApparentlyApparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As murumuru points outpoints out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’
Source Link
n.st
  • 8.4k
  • 4
  • 38
  • 57

Apparently,

recent versions of ssh started using pipes for non-TTY STDIO

so

there is no way for a bash script to tell whether a non-tty ssh command is being piped or not.

Since nohup only springs into action when it detects that stdout/stderr are connected to a terminal (and does nothing when the output goes to a pipe), and ssh's way of launching it looks like it's being piped, you get the behaviour you're seeing.


As muru points out, you can force ssh to allocate a tty by using the -t parameter:

$ ssh -t localhost "/usr/bin/nohup /bin/echo foo"
/usr/bin/nohup: ignoring input and appending output to ‘nohup.out’