Sep-26-2021, 04:25 AM
Update.
Here is a file I'm trying to execute remotely. It runs fine, no errors if executed manually, no errors.
but if called remotely it does nothing.
I'm not sure how to debug it.
script:
Here is a file I'm trying to execute remotely. It runs fine, no errors if executed manually, no errors.
but if called remotely it does nothing.
I'm not sure how to debug it.
script:
import subprocess,socket,shutil,time import os.path drl ='A' e_ip ='XX.X.X.X' mp_string = "net use"+" "+drl+":"+" \\\\"+e_ip+"\\"+"C$" # <-- String to mount dr_one ="\\\\"+e_ip+"\\"+"C$"+"\\"+"02"+"\\"+"logs" # <-- First Directory to get logs from delete_st = "net use"+" "+drl+":"+" "+"/delete /yes" sys_name = socket.gethostname() print(sys_name) # <-- System name make_dp ='C:\\02\\dt\\'+sys_name # <-- Directory to Copy Files to... if not os.path.exists(make_dp): os.mkdir(make_dp) monitor = 0 with open('C:\\02\\dt\\Num_OF_Files_Copied.txt','w') as num_of_f_copied : # <- Log files for the script num_of_f_copied.write(sys_name+'\n') try: subprocess.call(mp_string,shell=True) # <-- Mounting Cell if dr_one : print(' Dir Exits -',dr_one) num_of_f_copied.write(' Dir Exits -'+dr_one+'\n') for items in os.listdir(dr_one) : items=items.strip() itemspath = os.path.join(dr_one,items) #print(' ALL ITEMS', itemspath) if os.path.isfile(itemspath): items=items.strip() num_of_f_copied.write(' ITEMS -'+items+'\n') #print(' File Only ->', items) if 'Monitor.' in items : # <-- Monitor is in the name of the files print(' Monitor Files -> ',itemspath) num_of_f_copied.write(' MONITORS -> '+itemspath+'\n') try : shutil.copy(itemspath,make_dp) num_of_f_copied.write(' Copying Files -> '+itemspath+'\n') monitor+=1 except OSError as cpf : print(' Failed to copy files','\n') num_of_f_copied.write(' Failed to copy files'+'\n') except OSError as er : print(" Error scanning or Copying ->", er) print(' Number of files copied ->',monitor) subprocess.call(delete_st)Thank you.