I cut a part of the script that i tried to complete. I am expecting a new result for mylineS.split()[0]
after each iteration. outS.txt
and outT.txt
is result of commandC
for each iteration and result is different at each iteration. But mylineS.split()[0]
brings the first result for each iteration.
I guess something wrong with my approach, any idea?
B = 0
while B < len(Source_Tdevs):
devS = Source_Tdevs[B]
devT = Target_Tdevs[B]
subprocess.run(commandC, shell=True)
print (devS)
with open('outS.txt', 'r') as gS:
CS = len(gS.readlines())
mylineS = linecache.getline('outS.txt', CS -1)
Source_Tdevs_SGs.append(mylineS.split()[0])
**print (mylineS.split()[0])**
gS.close()
with open('outT.txt', 'r') as gT:
CT = len(gT.readlines())
mylineT = linecache.getline('outT.txt', CT - 1)
Target_Tdevs_SGs.append(mylineT.split()[0])
gT.close()
subprocess.run('del outS.txt, outT.txt', shell=True)
B= B + 1
commandC is one line above of subprocess.run(commandC, shell=True)
. I am writing bottom.
commandC = 'set "SYMCLI_OFFLINE=1" & set "SYMCLI_DB_FILE=C:\PROGRAM FILES\EMC\SYMAPI\DB\SYMAPI_DB.BIN" & call symaccess -sid %s list -type storage -dev %s > outS.txt & call symaccess -sid %s list -type storage -dev %s > outT.txt' % (
sid, devS, sid, devT)