diff --git a/README.md b/README.md index 6dc65bc..f922733 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # transfer_scripts A few scripts for estimating size and transferring files + +## Function + +transfer.pl - Use rsync to copy over files in a list or directory. + +estimate.pl - Estimate the total size of a list of files or a directory. + +fixlist.sh - fix your file list to the format these programs expect + +## Usage + + diff --git a/estimate.pl b/estimate.pl index e521014..25862ea 100755 --- a/estimate.pl +++ b/estimate.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # -# Author: Elia Farin 2024 +# Author: Elia Farin # Written: 8/9/24 # Modified: 8/9/24 # License: AGPL-3.0-or-later diff --git a/fixlist.sh b/fixlist.sh index 20fe060..ac941b5 100755 --- a/fixlist.sh +++ b/fixlist.sh @@ -5,7 +5,7 @@ # Modified: 8/9/24 # License: AGPL-3.0-or-later # -# Copyright (C) 2024 Elia Farin +# Copyright (C) 2024 Elia Farin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,7 +19,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - +# +# if [ -z "${1}" ]; then echo "Usage: ${0} " exit 1 diff --git a/transfer.pl b/transfer.pl index dd649fd..e43b7c9 100755 --- a/transfer.pl +++ b/transfer.pl @@ -1,9 +1,4 @@ #!/usr/local/bin/perl - -use strict; -use Getopt::Long; -use Proc::Pidfile; - # Transfer script transfer.pl # Author: Elia Farin # Written: 8/9/24 @@ -25,25 +20,17 @@ use Proc::Pidfile; # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -my $pidfile; -# if we are root, create a pidfile -if ($> = 0) { - my $pp = Proc::Pidfile->new( pidfile => "/var/run/transfer.pl.pid" ); -} else { -# if not, create our home pidfile - my $home = $ENV("$HOME"); - my $pp = Proc::Pidfile->new( pidfile => "$home/transfer.pl.pid"); -} - -# die if we cannot get pidfile lock -$pidfile = $pp->$pidfile(); +use strict; +use Getopt::Long; +use re; +my $username = getlogin() || (getpwuid($<))[0] || $ENV{LOGNAME} || $ENV{USER}; # sane defaults my $file = ""; -my $host = "192.168.42.100"; +my $host = ""; my $directory = "."; -my $user = "char"; -my $dest= "/home/char/Downloads/"; +my $user = $username; +my $dest= "/home/$username/Downloads/"; my $flags = "rvz"; my $verbose; my $help; @@ -87,9 +74,6 @@ else { help(); } -# remove the pidfile -undef $pp; - # help subroutine sub help { print "Usage: $ARGV[0] --file= --host= --directory= --user= --dest= --flags= [--verbose] [--help]\n