diff options
Diffstat (limited to 'rhimport.pm')
-rw-r--r-- | rhimport.pm | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/rhimport.pm b/rhimport.pm index 9081b4c..d33640d 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -31,7 +31,7 @@ use File::Spec; my $ssh_host = "airplay"; my $ssh_user = "rhimport"; -my $ssh_key_file = "id_dsa"; +my $ssh_key_file = "id_dsa"; # "/etc/rhimport/import_key"; my $ssh_dir = "/programm/.rhimport"; my $rdimport_wrapper = "/usr/local/bin/dropbox_newfile.pl"; @@ -156,10 +156,13 @@ sub import_playlist my $cnt = 0; my $ret = 0; + my $log = ""; for my $entry ( @entries ) { $progress_cb->($cnt, $num_entries, $entry) if($progress_cb); - $ret = import_file($entry, $dropbox, $error_cb); + my $out; + ($ret, $out) = import_file($entry, $dropbox, $error_cb); + $log .= "\n--- $entry ---\n$out\n"; last if($ret == 0); $cnt++; @@ -171,7 +174,7 @@ sub import_playlist $progress_cb->($cnt, $num_entries, "Import abgebrochen!") if($progress_cb); } - return $ret; + return ($ret, $log); } sub import_single @@ -179,16 +182,17 @@ sub import_single my ($file, $dropbox, $progress_cb, $error_cb) = @_; print "Starting import from file $file to $dropbox\n"; $progress_cb->(0, 1, $file) if($progress_cb); - my $ret = import_file($file, $dropbox, $error_cb); + my ($ret, $out) = import_file($file, $dropbox, $error_cb); if($ret) { $progress_cb->(1, 1, "Import abgeschlossen!") if($progress_cb); } else { $progress_cb->(0, 1, "Import abgebrochen!") if($progress_cb); } - return $ret; + return ($ret, $out); } -sub scp_put_file { +sub scp_put_file +{ my ($file) = @_; my @cmd = ( 'scp', '-prqB' , '-i', $ssh_key_file, $file, "$ssh_user\@$ssh_host:$ssh_dir/" ); my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -203,7 +207,8 @@ sub scp_put_file { return $errstr; } -sub ssh_exec_command { +sub ssh_exec_command +{ my ($command) = @_; my @cmd = ( 'ssh' , '-i', $ssh_key_file, "$ssh_user\@$ssh_host" , $command ); my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -252,7 +257,7 @@ sub import_file } print "imported OK\n"; - return 1; + return (1, $out); } sub delete_file |