[cs615asa] HW3 Getting the hostname

Tejas tnadkarn at stevens.edu
Sat Mar 3 17:15:04 EST 2012


Thanks, I was able to split it into a list then join it again as a 
string and it works! :)

On 03/03/2012 04:54 PM, Jan Schaumann wrote:
> 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
> _______________________________________________
> cs615asa mailing list
> cs615asa at lists.stevens.edu
> https://lists.stevens.edu/cgi-bin/mailman/listinfo/cs615asa



More information about the cs615asa mailing list