Leser: 1
7 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl -w use strict; use warnings; use Expect; # command and parameters to execute my $command = "sshfs"; my @params = ("user\@server:/home/user", "~/remote_home"); # data to be sent by expect my $password = "********"; # spawn a new command my $exp=new Expect(); $exp->debug(3); # 0,1,2,3 $exp->spawn($command, @params) || die "Error: Cannot spawn process. $!\n"; # wait for the password prompt $exp->expect(5,-re=>'assword:') or die "No password prompt\n"; #print("\nError: " . $exp->error() . "\n"); # send password $exp->send("$password\n"); $exp->soft_close(); exit(0);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
localuser@vigo:~/perl$ ./expect.pl
Spawned 'sshfs user@server:/home/user /home/localuser/home'
spawn id(3)
Pid: 8937
Tty: /dev/pts/1
at /usr/share/perl5/Expect.pm line 164
Expect::spawn('Expect=GLOB(0x8345394)', 'sshfs', 'user@server:/home/user', '/home/localuser/home') called at ./expect.pl line 17
Starting EXPECT pattern matching...
at /usr/share/perl5/Expect.pm line 533
Expect::expect('Expect=GLOB(0x8345394)', 5, '-re', 'assword:') called at ./expect.pl line 26
user@server's password: Closing spawn id(3).
at /usr/share/perl5/Expect.pm line 1311
Expect::soft_close('Expect=GLOB(0x8345394)') called at ./expect.pl line 32
Got EOF from spawn id(3).
spawn id(3) closed.
Pid 8937 of spawn id(3) exited, Status: 0x00
Closing spawn id(3).
at /usr/share/perl5/Expect.pm line 1388
Expect::hard_close('Expect=GLOB(0x8345394)') called at /usr/share/perl5/Expect.pm line 1578
Expect::DESTROY('Expect=GLOB(0x8345394)') called at ./expect.pl line 0
eval {...} called at ./expect.pl line 0
localuser@vigo:~/perl$
Quote1) Ich will ja nicht einem interaktiven Programm vorgaukeln dass da ein Mensch sitzt, denn es sitzt wirklich ein Mensch da, ich will nur den Input/Output weiterleiten. Ein Proxy quasi.
7 Einträge, 1 Seite |