Takeaway Sheet: The Basics of Launching Scripts
Glossary
SSH — a technology that makes it possible to manage operating systems on virtual machines securely.
Practice
1# Connecting to the virtual machine from the command line23ssh -i <path_to_private_key> ubuntu@<public_dns>
1# The minimal Python script code23#!/usr/bin/python45if __name__ == "__main__":6 # Code
1# Getting command line arguments23arguments = sys.argv45# Input parameters' format67unixOptions = "s:e:" # parameters in UNIX format8gnuOptions = ["start=", "end="] # parameters in GNU format910# Check whether input parameters match the format11# indicated in unixOptions and gnuOptions12try:13 arguments, values = getopt.getopt(argumentList, unixOptions, gnuOptions)14except getopt.error as err:15 print (str(err))16 sys.exit(2) # Stop execution if input parameters are incorrect1718# Read the values from the string with input parameters1920start = ''21end = ''22for currentArgument, currentValue in arguments:23 if currentArgument in ("-s", "--start"):24 start = currentValue25 elif currentArgument in ("-e", "--end"):26 end = currentValue
1# Launching a Python script containing parameters23python params_test.py --start='start' --end='end'
1# Transmitting a file to a virtual machine23scp -i <path_to_private_key> <path_to_a_local_file> ubuntu@<public_dns>:
1# Calling cron schedule editor23crontab -e