Lab9-F23
.pdf
keyboard_arrow_up
School
Northern Kentucky University *
*We aren’t endorsed by this school
Course
383
Subject
Information Systems
Date
Dec 6, 2023
Type
Pages
2
Uploaded by KidFire12260
CIT383-Lab9
@CIT383 Instructors
1
CIT383
–
Scripting 1
Lab 9
Network Services
Objectives:
•
Demonstrate ability to write scripts to access remote resources using FTP
•
Demonstrate continued ability to use argument parsers in Python scripts
Tasks:
In this Lab, you would write a python script utilizing
only
the following python libraries/modules:
socket
,
ftplib
and
httplib
. Your script would have a menu system from which a user would select a task.
A.
Working with FTP
1.
Log in to VM2 (CIT383-001_username_CentOS9-2) as "student" and VM1 (CIT383-
001_username_CentOS9-1) as "ftpuser" using the same password for both VMs. Make
sure to note the IP addresses of both VM1 and VM2.
2.
Download the files "file1.csv," "file2.csv," "file3.csv," and "file4.txt" from the Canvas
assignment linked in this lab instruction to the "cit383F2023" directory in the home
directory of "ftpuser" on VM1. You may choose to create additional files and dump
them into that directory.
3.
On VM1 (CIT383-001_username_CentOS9-1) under the "student" account, create a
script with the following functions:
a)
Upload Function (
upload_file()
): accept a filename in the current working
directory and upload it to the "cit383F2023" directory on VM2 (CIT383-
001_username_CentOS9-2). Display an error message if the specified file does
not exist.
b)
Download Function (
download_file()
): Prompt the user to provide a file
extension (file type) and download all files with the specified extension from the
"cit383F2023" directory on VM2 to the current working directory on VM1. If no
files with the specified extension are found, display a message indicating so.
c)
Execute Command Function (
exec_command()
): executes the
“
ls
”
command on
the target computer listing only files of a certain type and returns that list to the
computer from which the code is executed. Properly format the names of the
files returned. You may choose to use a table for this.
B.
Putting it all together
Mandatory Argument
CIT383-Lab9
@CIT383 Instructors
2
Mandatory (required) Positional
Argument
Description
FTP_SERVER_IP
This represents the IP address of the FTP
server that is being reached. Assume the
default port for the FTP server (21)
Implement the following options:
Option
Required
Argument
Description
-h
<none>
Display the help for this program
-u
filename
If present, this option uploads the file specified from
the current working directory of the current
computer to VM2. (Task 3a)
-d
fileExtension
If present, this option downloads all files with the
specified extension from VM2 to the current working
directory. (Task 3b)
-l
fileType
If present, return the files with extension
fileType
within the
cit383F2023
directory. These should be
returned to the screen of the computer executing the
script. The list should be appropriately formatted.
(Task 3c)
C.
Submit your script via the Canvas assignment from which this file is linked.
What to submit:
Submit a single Python file containing the implementation of the above stated
requirements. Name your file using the following format:
Group_[your_group_number]_lab9.py
and submit the file via the linked Canvas assignment.
Remember to replace
[your_group_number]
with the number of your assignment group before
submitting the file.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help