0

I'm trying to execute commands in a heredoc block SSH session using something like this:

ssh -tt user@domain << 'END' > ./file.txt

    some command

END

The command is executed and saved a portion of the output at file.txt. The problem is that the program prompt for an ENTER or space to continue showing the output (the entire output have thousands of lines)

How Can I send one or more ENTER after the first command? I tried using some command\n\n\n but doesn't works.

Michael Becerra
  • 401
  • 1
  • 3
  • 15

1 Answers1

1

Just add a blank line to the heredoc input.

But the command can actually read from a terminal, not a standard input. Then this won't work.

You are possibly causing this trouble yourself by forcing a pseudo-terminal allocation using the -t switch. Without pseudo terminal commands usually do not paginate (not having "terminal" to paginate against) and tend to use standard input for reading.

Try remove -t switch. It should not be used for automation anyway. It's for interactive sessions.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992