in reply to SFTP and the Pointy-Haired manager
I've never used Expect::Simple, but here it is in plain Expect:
#!/usr/bin/perl use strict; use warnings; use Expect; my $REMOTE = 'name@server:/dir'; my $LOCAL = 'file'; my $cmd = "sftp $REMOTE"; my $exp = Expect->spawn($cmd) or die; $exp->expect(120, "password: ") or die; $exp->send("dummy\r"); $exp->expect(120, "sftp> ") or die; $exp->send("put $LOCAL\r"); $exp->expect(600, "sftp> ") or die; $exp->send("bye\r"); $exp->close();
It behooves you to add reasonable messages to the die commands, since all Expect scripts inevitably break.
The code may need tweaking depending on software versions. For the record, here's what I used:
$ perl -v This is perl, v5.6.1 built for i386-linux $ perl -MExpect -le 'print $Expect::VERSION' 1.15 $ strings `which sftp` | grep sftp-client @(#)$OpenBSD: sftp-client.c,v 1.33 2002/06/23 09:30:14 deraadt Exp $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SFTP and the Pointy-Haired manager
by FatDog (Beadle) on Jul 08, 2004 at 03:41 UTC | |
by FatDog (Beadle) on Jul 08, 2004 at 17:28 UTC |