Thread Net::SFTP - Verbindung klappt nicht
(10 answers)
Opened by Stefan_S at 2023-04-06 14:56
Wunderbar, so klappt es mit der Verbindung und dem Dateiupload. Danke.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 use strict; use warnings; use Net::SSH2; # Variablen festlegen my %sftp = ( sftp_server => 'server', sftp_user => 'user', sftp_pw => 'passwort', sftp_file => "zielpfad/zieldatei", ); # Verbindung zum FTP-Server aufbauen my $ssh2 = Net::SSH2->new(); $ssh2 -> connect ( $sftp {sftp_server} ) or $ssh2 -> die_with_error; $ssh2 -> auth_password ( $sftp {sftp_user} , $sftp {sftp_pw} ) or $ssh2->die_with_error; my $sftp = $ssh2 -> sftp() or $ssh2 -> die_with_error; # Datei hochladen my $fh = $ssh2 -> scp_put ( "quellpfad\\quelldatei", $sftp {sftp_file} ) or $sftp -> die_with_error; # Verbindung zum FTP-Server beenden $ssh2 -> disconnect or $ssh2 -> die_with_error; |