Re: [Ssh-sftp-perl-users] Using Net::SSH2 as a file handle
Brought to you by:
dbrobins
|
From: David R. <dbr...@cp...> - 2006-01-20 17:24:08
|
On Friday January 20, 2006 03:52, Bryan Bueter wrote:
> >> I dont fully understand channels, but from what I remember with
> >> Net::SSH::Perl, a new channel had to be created every time you sent a
> >> command. But now there is a Net::SSH2::Channel->shell() function,
> >> perhaps
> >> there is a way to launch a shell on a channel and interact with that?
> >
> > There is. The shell() function just makes the channel a shell channel,
> > and you can send commands to it.
>
> Does this act like a normal shell? Primarily does it just exec shell and
> pass IO back and forth, or is it interpreted somehow?
I think it does act like a normal shell; you'll probably have to test it
though. I'm not sure what the ssh spec says regarding the actual shell at
the other end.
> >> I see Net::SSH2::Channel is itself a tied filehandle, but attempts to
> >> directly manipulate that dont result in what I expected.
> >
> > In what way? If you can give details I'll try to fix them.
>
> With this snipit of code:
>
> -- snip -->
> use Net::SSH2;
> use Expect;
>
> my $ssh2 = Net::SSH2->new();
> $ssh2->connect("127.0.0.1");
> $ssh2->auth(username => scalar getpwuid($<), interact => 1) or die;
>
> my $chan = $ssh2->channel();
> $chan->shell();
>
> my $exp_obj = Expect->exp_init( $chan );
> <-- end --
>
> Returns the following when I run the script:
> $ ./test.pl
> [user username]
> Password: ERROR: cannot find method `FILENO' in class Expect at ./test3.pl
> line 13
>
> Line 13 is the expect init line. Maybe its an expect bug, but I dont
> think so. I've been able to open expect on raw sockets before. So i
> think it has something to do with the way channel() sets itself up.
Ah, then there's the problem. Fileno tries to get a real Unix filehandle out
of the object; since it isn't a real Unix file, you won't get one.
Maybe something can be worked out with pipes so that it really is a handle
(create a pipe, send the channel data to one end, give expect the other end)
but it's beyond the scope of the current implementation.
--
Dave
Isa. 40:31
|