ソース フォルダーから宛先フォルダーにファイルをコピーする Python スクリプトを作成しました。スクリプトはローカル マシンで正常に動作します。
ただし、ソースを DMZ にインストールされたサーバーにあるパスに変更し、宛先をローカル サーバーのフォルダーに変更しようとすると、次のエラーが発生しました。
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\reports'
そして、ここにスクリプトがあります:
import sys, os, shutil
import glob
import os.path, time
fob= open(r"C:\Log.txt","a")
dir_src = r"\reports"
dir_dst = r"C:\Dest"
dir_bkp = r"C:\Bkp"
for w in list(set(os.listdir(dir_src)) - set(os.listdir(dir_bkp))):
if w.endswith('.nessus'):
pathname = os.path.join(dir_src, w)
Date_File="%s" %time.ctime(os.path.getmtime(pathname))
print (Date_File)
if os.path.isfile(pathname):
shutil.copy2(pathname, dir_dst)
shutil.copy2(pathname, dir_bkp)
fob.write("File Name: %s" % os.path.basename(pathname))
fob.write(" Last modified Date: %s" % time.ctime(os.path.getmtime(pathname)))
fob.write(" Copied On: %s" % time.strftime("%c"))
fob.write("\n")
fob.close()
os.system("PAUSE")