As Sidhekin and I have pointed out, you were trying to feed perl commands into ksh. Don't do that, it chokes. Wrapping perl commands into ksh syntax is tedious, so you would it find nice to talk directly to perl, I guess. Here's a small script that does the trick. perl will read one line from STDIN at a time, eval it and print a prompt:
#!/usr/bin/perl $| = 1; # make output unbuffered prompt(); while(<STDIN>) { # read 1 line... eval $_; # ...doit... warn $@ if $@; # ...complain if error prompt(); # ...and print prompt; } sub prompt { print "\n;# perl > " } __END__

Place that script in your home directory on the remote server, and call perl to execute it:

$telnet->cmd('perl perlshell.pl');
Now you can talk to perl.
print $telnet->cmd('print scalar localtime(time)'); Thu Jun 29 15:58:52 2006 print $telnet->cmd('print $^X'); /usr/bin/perl
Note that to logout you have to $telnet->cmd('exit') twice, one time to terminate perl, the next to terminate your login shell.

update: One exit alone leaves you again at the ksh prompt. Note also that you cannot issue multiline statements, as the remote perl interpreter reads one line at a time.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: Remote server file access issue by shmem
in thread Remote server file access issue by qsl

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.