Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Perl program that creates a backup copy of the file (or files) specifie

ID: 3885973 • Letter: C

Question

Create a Perl program that creates a backup copy of the file (or files) specified by the user.

The user must be able to specify the file name-- or names-- on the command line using shell expansions

If no files are specified on the command line, the program should either prompt for a filename or describe the problem and exit cleanly

Each specified file will be copied to a new filename that preserves the original filename and adds a unique suffix

The new filename must not previously exist (in other words, do not overwrite any older files)

The program must detect and report errors and should prevent unexpected consequences

The program must display the new name of each file that it copies

Explanation / Answer

Here is the backup of the perl script using FTP:

# set the directory where you will keep the backup files

$backup_folder = '/user/venkat/venkatesh';

# the config file is a text file with a list of the databases to backup

# this should be in the same location as this script, but you can modify this

# if you want to put the file somewhere else

my $config_file = dirname($0) . "/backup.config";

# Here is where you will put your FTP server name (or IP address)

# and your FTP username and password

my $host = "server_name.com";

my $user = "username";

my $password = "password";