Homework 5
Sample XLS files now available at http://www.cs.rpi.edu/~lallip/perl/directories.xls and http://www.rpi.edu/~lallip/otherdirs.xls.
This assignment will get you used to searching the standard modules as well as CPAN to decrease the overall amount of work you need to do to solve a programming task in Perl.
To complete this assignment most effectively and efficiently, you will have to use both standard and CPAN modules, not all of which we've covered in class.
Write a program that allows the user to enter several options and values on the command line, in any order:
--url- a web site to retrieve.--ftp- the name of an FTP server to which you will upload a file.--user- the username with which you'll log on to the FTP site.--debug- if given, will print out status messages at each step of the process.
Once you've gotten the arguments off the command line, retrieve the .xls file at the given URL, and store it in the current working directory.
Parse this Excel file to obtain a list of directories from it. The directories will be listed in cells in the first column of the first tab of the Excel file.
Create a new Excel file. In this file, you will write the directory
names found in the first file to the first row of the new file. Under
each directory, print a list of all files found in that
directory (on solaris.remote.cs.rpi.edu), one filename per
cell.
For example, if the Excel file found at the URL contained:
| /cs/lallip/public |
| /usr/dict |
then the Excel file you create would contain:
| /cs/lallip/public | /usr/dict | BankAccount.pm | words |
| ica2.pl | |
| submit.pl |
Once you have created this new Excel file, prompt the user for the password for the FTP server and username specified on the command line. Make sure the user's typing is hidden, so that the password does not actually show up on the screen. Upload the Excel file you created to the FTP server. (Make sure you set transfers to binary mode, since you're uploading a non-text file).
If the user supplies the --debug option on the command line
(which does not take a value), then your script should print out what it's doing
at each step of the way. ("Now retrieving Excel file from $url",
"Now FTP'ing $file to $server", etc). If --debug is
not provided, your script should not generate any output to the screen.
Notes
- All RPI students have access to an FTP server:
ftp.rpi.edu. Log on with your RCS Id and password. After uploading, you'll be able to see the files by logging on to the RCS network (code>rcs-sun4.rpi.edu for example).
Grading Criteria
| Parse Command Line | 5 |
|---|---|
| Retrieve Excel file from web | 10 |
| Parse Excel file | 15 |
| Obtain files in directories | 2.5 |
| Write new Excel file | 15 |
| Read Password without displaying it | 10 |
| Upload FTP file | 12.5 |
| Print Debug info | 5 |
| No Warnings | 5 |
| Error Checking | 5 |
| Code Style | 5 |
| Output Style | 5 |
Penalties
- Failure to compile: 50 points
- Late (< 14 hours): 20 points
- Late (> 14 hours): 100 points
Submission Instructions
To submit, log on to solaris.remote.cs.rpi.edu and run ~lallip/public/submit.pl.
You may submit infinite times, only the last submission is graded. Your final submission is due
at 11:59:59pm, Wednesday, April 21, 2010
