The program

We are going to use the script from InfolabClusterComputeHowtoSingle that we modified just so it prints out the arguments passed to it. You can download the script here SingleCoreVariables.py.

   1 #!/usr/bin/python2.7
   2 
   3 import socket, datetime, time, getpass, sys
   4 
   5 start = datetime.datetime.now()
   6 hostname = socket.gethostname().split('.')[0]
   7 username = getpass.getuser()
   8 time.sleep(10)
   9 end = datetime.datetime.now()
  10 
  11 dfmt = "%Y-%m-%d %H:%M:%S"
  12 print "Started: %s Finished: %s Host: %s User: %s" % (start.strftime(dfmt), end.strftime(dfmt), hostname, username)
  13 print "My arguments:"
  14 print sys.argv

The script starts, records the current time, figures out the hostname it is running on and the username it is running as. Then it sleeps for 10 seconds (so we at least have some impact on the cluster), records the time again and prints out a string that may look a little something like this (if we called it with myarg1, myarg2 and myarg3, of course):

Started: 2012-10-16 18:19:47 Finished: 2012-10-16 18:19:57 Host: ilhead1 User: akrevl
My arguments:
['./SingleCoreVariables.py', 'myarg1', 'myarg2', 'myarg3']