I can use only python 2.6.6 and subprocess is not working so I need to use only os module Below is the program
import os
server = raw_input("server name:")
var = "symaccess -sid 239 list -type init | grep \"{0}\"".format(server)
wwn = os.system(var)
init = 'symaccess -sid 239 -type init show {0}'.format(wwn)
print init
os.system(init)
above is the script I used to add an output of one os.system
to another os.system
, I got the first os.system
executed but for the second one i.e os.system(unit)
is not coming because the output of os.system(var)
should be assigned to a variable to wwn
. could someone tell how to assign a variable to os.system(init)
Here in this script, the output of var says some X
should be assigned to own but it's not taking X
it's taking it as 0
. So need your help to sort this why it is taking zero instead of X
. Finally this X
should be placed at init
variable at {0}
.
os.system
does not return the output of the command - it returns the errorlevel.
If you need command output, use
wwn = os.popen(var).read()
That will assign the output from command var
to wwn
.
Be warned - the output is returned completely, with the trailing newline. You might want to strip()
it before using it.