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;