saunite has asked for the wisdom of the Perl Monks concerning the following question:
I am doing a simple perl script to connect to a remote machine via ssh and open an interactive terminal
The connection works fine, the problem is that, after I am connected to a Solaris box, if I try to open a file in vi, it shows the whole screen with the ~ at the beginning of each line, even though the last line correctly shows the file name and number of characters in the file, but the text inside the file is not shown, and also, if I try to edit it, the ~ continues there as if they were part of the text.
I tried the same on a Linux box, and what happened was that I could edit the file, but the file was inside a small "box" in the left upper corner of my terminal, instead of being the whole size of my terminal.
I am using the code below:
#!/usr/bin/perl use Expect; my $ip = "10.0.0.1"; my $user = "user"; my $passwd = 'user'; my $timeout = 30; my $command_prompt = '[#%\$>]|\:\/\s*$|TERM\ \=\ \([a-z]*\)'; my $passwd_prompt = '([p|P]ass|[p|P]ass[w|W]or[d|t]|[c|C]ontrase.a|Ent +er passphrase for key )\s*:\s*$'; my $user_prompt = '([l|L]ogin|[u|U]suario|[u|U]ser-?[n|N]ame|[u|U]ser) +\s*:\s*$|[n|N]ame\s*(.*:.*):\s*'; my $conn_command = "ssh -l $user -p 22 $ip"; my $ct = Expect->spawn($conn_command) or die "Error $conn_command: $!\ +n"; $ct -> expect ( $timeout, [ $user_prompt, sub { $ct -> send ( "$user\n" ); exp_continue; } ], [ $passwd_prompt, sub { $ct -> send ( "$passwd\n" ); exp_continue; } ], [ $command_prompt, sub { $ct->interact( \*STDIN, __TESTING__TESTING__ ); } ], ); $ct->close();
Does anyone have an idea of why is it behaving like that?
Thanks very much in advance!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Expect and interact with vi
by kcott (Archbishop) on Sep 14, 2012 at 10:21 UTC | |
by saunite (Initiate) on Sep 14, 2012 at 21:15 UTC |