Well … I realized that I missed important thing in my script. The goal of the script is to figure out if account is Active. For that reason I still need to ‘grep’ for this string ‘Account active Yes’
Hence I modified my original script and put ‘grep’ in subprocess.call but it stopped to work.
I’ve got this error and it’s looping:
python WhileLoop_account-TEST.py
The system cannot find the path specified.
**
Here is my script now:
import subprocess
import time
import winsound
import datetime
Account = 'Joe'
#Account = 'Jen'
x = subprocess.call(["'net', 'user', '/domain', Account | grep 'Account active Yes'"], shell=True)
# Clear 25 lines of screen for convinience
def clear():
print('\n' * 25)
clear()
while True:
if x == 0:
print ("********************\n")
print ("\n")
print ("Account " + Account + " is ACTIVE")
print (datetime.datetime.now().strftime('%Y-%m-%d %H:%S'))
winsound.Beep(500,5000)
exit()
else:
time.sleep(30)
print ("Still trying ... WAIT!!")
x = subprocess.call(["'net', 'user', '/domain', Account | grep 'Account active Yes'"], shell=True)
clear()
Could some help me with the script?
Thanks