6 Commits
1.1 ... 1.2

Author SHA1 Message Date
wasabi
a40e1bc0fd moved .gitignre to .gitignore 2024-08-09 20:51:23 -05:00
wasabi
77f295ba56 fixed spelling mistake in gitignre 2024-08-09 20:51:10 -05:00
wasabi
f4b32c93da fixed gitignore 2024-08-09 20:49:54 -05:00
wasabi
b685d21e3f Updated to print progress message before each transfer 2024-08-09 20:49:09 -05:00
wasabi
034afa8b53 updated install to install one of the dependancies 2024-08-09 20:48:42 -05:00
wasabi
2d87c5392c added gitignore for testing 2024-08-09 20:48:26 -05:00
3 changed files with 28 additions and 6 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
testfolder/*
test*.txt

View File

@@ -30,3 +30,5 @@ cp ./fixlist.sh /usr/local/bin/fixlist.sh
chmod 755 /usr/local/bin/transfer.pl chmod 755 /usr/local/bin/transfer.pl
chmod 755 /usr/local/bin/estimate.pl chmod 755 /usr/local/bin/estimate.pl
chmod 755 /usr/local/bin/fixlist.sh chmod 755 /usr/local/bin/fixlist.sh
cpan install Getopt::Long

View File

@@ -1,4 +1,4 @@
#!/usr/local/bin/perl #!/usr/bin/env perl
# Transfer script transfer.pl # Transfer script transfer.pl
# Author: Elia Farin # Author: Elia Farin
# Written: 8/9/24 # Written: 8/9/24
@@ -22,15 +22,14 @@
# #
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use re;
my $username = getlogin() || (getpwuid($<))[0] || $ENV{LOGNAME} || $ENV{USER};
# sane defaults # sane defaults
my $file = ""; my $file = "";
my $host = ""; my $host = "";
my $directory = "."; my $directory = ".";
my $user = $username; my $user = getlogin() || (getpwuid($<))[0] || $ENV{LOGNAME} || $ENV{USER};
my $dest= "/home/$username/Downloads/"; my $dest= "/home/$user/Downloads/";
my $flags = "rvz"; my $flags = "rvz";
my $verbose; my $verbose;
my $help; my $help;
@@ -45,6 +44,7 @@ my $result = GetOptions ( "file=s" => \$file,
"verbose" => \$verbose, "verbose" => \$verbose,
"help" => \$help); "help" => \$help);
print "file: $file, host: $host, directory: $directory, user: $user, dest: $dest flags: $flags verbose: $verbose help: $help\n";
### Begin main logic ### Begin main logic
# help catch # help catch
if ($help) { if ($help) {
@@ -53,24 +53,42 @@ if ($help) {
} }
# If we have all the right arguments, begin the copy # If we have all the right arguments, begin the copy
elsif (length $file && length $host && length $user && length $dest && length $directory) { elsif (length $file && length $host && length $user && length $dest && length $directory) {
#print "in elsif block\n";
# Open our filehandle # Open our filehandle
open my $info, $file or die "Could not open $file: $!"; open my $info, $file or die "Could not open $file: $!";
my $linenum = 0;
while( my $iterline = <$info>) {
#print "in first while loop\n";
$linenum++;
}
close $file;
open $info, $file or die "Could not open $file: $!";
my $xfernum = 0;
# read line by line # read line by line
while( my $line = <$info> ) { while( my $line = <$info> ) {
#print "in second while loop\n";
$xfernum++;
chomp $line; chomp $line;
# actual copy logic # actual copy logic
if (length $verbose) { if (length $verbose) {
#print "in verbose section";
print "\n\nTransferring object $xfernum of $linenum\n\n";
system("rsync", "-vvv", "-$flags", "$directory/$line", "$user\@$host:$dest"); system("rsync", "-vvv", "-$flags", "$directory/$line", "$user\@$host:$dest");
} else { } else {
#print "in non-verbose section";
print "\n\nTransferring object $xfernum of $linenum\n\n";
system("rsync", "-$flags", "$directory/$line", "$user\@$host:$dest"); system("rsync", "-$flags", "$directory/$line", "$user\@$host:$dest");
} }
} }
close $file;
} }
# if we fail the variables check, print usage help # if we fail the variables check, print usage help
else { else {
#print "In help else\n";
help(); help();
} }