Hi all,

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!!!


In reply to Using Expect and interact with vi by saunite

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.