Fake um terminal e "digite" os dados necessários. Primeiro o nosso programa de teste testproggie
no sistema remoto
#!/usr/bin/env perl
use 5.14.0;
use warnings;
say "one thing";
open my $fh, '<', '/dev/tty' or die "nope on /dev/tty: $!\n";
readline $fh;
say "another thing";
O que de fato falhará se você remotamente uma nova linha para ele
$ printf "\n" | ssh test.example.edu ./testproggie
one thing
nope on /dev/tty: No such device or address
$
Então, agora nós falsificamos um terminal com remotenl
no sistema local
#!/usr/bin/env expect
#set timeout 999
#match_max 99999
# this assumes the remote side does not do anything silly with
# the shell; if it does you may need to spawn a remote shell
# and then {send "./testproggie\r"} to that and then...
spawn -noecho ssh -q -t test.example.edu ./testproggie
# this can be improved if you know what the line before the
# wait-for-the-return-key will contain
expect -re .
send "\r"
expect eof
# this could be simplified with better expect calls, above
regexp {([^\r\n]+)\r\n$} $expect_out(buffer) unused lastline
puts ">>>$lastline<<<"
e execute-o
$ ./remotenl
one thing
another thing
>>>another thing<<<
$