[cs615asa] HW3 Getting the hostname

Jan Schaumann jschauma at stevens.edu
Sat Mar 3 16:54:28 EST 2012


Tejas <tnadkarn at stevens.edu> wrote:
> This is the code and output using Python interactively that I'm using in  
> my script:
> parallels at ubuntu:~$ clear
> parallels at ubuntu:~$ export EC2_RUN_INSTANCES_FLAGS="-k ec2key"
> parallels at ubuntu:~$ env | grep EC2_RUN
> EC2_RUN_INSTANCES_FLAGS=-k ec2key
> parallels at ubuntu:~$ python
> Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
> [GCC 4.6.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os
> >>> osflags=os.environ["EC2_RUN_INSTANCES_FLAGS"]
> >>> print osflags
> -k ec2key

What is the type of 'osflags' here?

> >>> from subprocess import Popen, PIPE
> >>> process = Popen(["ec2-run-instances", "ami-b232d0db", osflags],  
> stdout=PIPE)

Here you are constructing a command that invokes 'ec2-run-instances'
with the two arguments 'ami-b232d0db' and '-k ec2key'.

Think about how you can take the string '-k ec2key' and turn it into the
list [ '-k', 'ec2key' ]...

-Jan


More information about the cs615asa mailing list