I've got a perl script that automatically logs me via ssh
by spawning ssh with Expect.pm
.
It actually works pretty well and here is my ouput:
$ ngh bestServerEver
GPG Pass :
root@**********'s password:
Linux **** 2.6.32-042stab059.7 #1 SMP Tue Jul 24 19:12:01 MSK 2012 x86_64 GNU/Linux
motd!!!!!!!!!!
Last login: Mon Feb 4 22:18:10 2013 from *******************
bash
[root@******:~]$ bash
[root@******:~]$
I'm trying to suppress this output to get to the server shell directly after typing my command. Like that:
$ngh BestServerEver
root@server#
I've tried that answer: How can I suppress STDOUT temporarily in a Perl program?
I've also tried:
local (*OUT, *ERR);
open OUT, ">&STDOUT";
open ERR, ">&STDERR";
close STDOUT;
close STDERR;
print "don't print";
open STDOUT, ">&OUT";
open STDERR, ">&ERR";
Both are okay when it's about standard STDOUT but Expect seems to be a different kind of handle or whatever.
I've also tried setting:
$exp->stty("-echo");
But it did not hide anything
Finally, here is my code http://pastebin.com/pSL3AwBW if you have some tips to give me on how to hide that junk.