Search This Blog

Monday, June 2, 2008

Get command line parameters for a program in PYTHON

Example of a function by which you can get command line parameters for a program in python Note : Kindly do the indentatoin of your own.........
def GetCommandLineParameters(commandline_temp):

   position = 0
   fcrontmpfile,entrytoignore,fcronsourcefile = '','',''
   length = len(commandline_temp)

   while position < fcrontmpfile =" commandline_temp[position]" entrytoignore =" commandline_temp[position]" fcronsourcefile =" commandline_temp[position]" style="font-weight: bold;">Example of a Usage Function
def Usage():
   print "\nPlz go through the USAGE."
   print "Note : \n\t*\tThis suid can read or write in a fcron file. ignoreprogram is the entry which \n\t\tyou would like
to remove to avoid duplication. \n\n\t*\tIt would be prefered to give the full program name with the path so that \n\t\tther
e is no duplication with the new entry. \n\n\t*\t--fcrontempfile and --ignoreprogram are mandatory if you want to read the \
n\t\tfcron or --fcronsourcefile is mandatory if u want to change the fcron of the firewall."
   print "\nUSAGE: python writeinfcron.py [OPTION...]"
   print "-------------------------------------------------------------------------------------------------"
   print "\n--fcrontempfile          ------->        A temp file with path where the fcrondata will be written."
   print "--ignoreprogram          ------->        An entry which you would like to ignore."
   print "--fcronsourcefile        ------->        Fcron Source file which will be wriiten in the cron file"
   print "-------------------------------------------------------------------------------------------------"

1 comment:

Anonymous said...

Well written article.