【问题标题】:McAfee Update download scriptMcAfee 更新下载脚本
【发布时间】:2012-04-03 09:20:59
【问题描述】:

我正在设置安装了 McAfee 的 PC,并被告知我需要停止程序联机以下载更新 (DAT)。我需要创建一个脚本来从 McAfee 网站下载 dat 文件,并将此文件放在 McAfee 可以访问和安装的服务器上。

过去有没有人这样做过。

【问题讨论】:

    标签: powershell scheduled-tasks mcafee


    【解决方案1】:

    我实际上已经这样做了。我已经有一两年没有测试过这个脚本了,但这就是我正在使用的。这不是用 Powershell 编写的,但如果您更改目录,我认为这可以在 Windows 上运行。

    #!/usr/bin/python
    
    import ftplib
    import tarfile
    import shutil
    import os
    import re
    import time
    
    scannerDir = "/usr/local/uvscan/"
    tmp = "/tmp/avscanner/"
    
    def downloadDat():
        datfile = ""
        r = re.compile("^avvdat")
        ftp = ftplib.FTP("ftp.nai.com", "anonymous", "email@yourdomain.com")
        ftp.cwd("/pub/datfiles/english")
        list = ftp.nlst()
        for x in list:
            if r.search(x):
                datFile = x
        f = open(tmp + "datfile", 'wb')
        ftp.retrbinary("RETR " + datFile, f.write)
        f.close()
        ftp.quit()
    
    def unpackDat():
        tFile = tarfile.open(tmp + "datfile", 'r')
        for f in tFile.getnames():
            tFile.extract(f, tmp)
    
    def createDirs():
        if os.path.isdir(tmp) == False:
            os.mkdir(tmp, 0700)
        os.chown(tmp, 0, 95)
        os.chmod(tmp, 0755)
    
    def doCleanup():
        shutil.rmtree(tmp)
    
    def installFiles():
        shutil.copyfile(tmp + "/avvclean.dat", scannerDir + "/avvclean.dat")
        shutil.copyfile(tmp + "/avvnames.dat", scannerDir + "/avvnames.dat")
        shutil.copyfile(tmp + "/avvscan.dat", scannerDir + "/avvscan.dat")          
    
    def isOld():
        if os.path.isfile(scannerDir + "/avvclean.dat"):
            if time.time() - os.path.getctime(scannerDir + "/avvclean.dat") < 80000:
                return True
            else:
                return False
        else:
            return True
    
    def main():
        if isOld():
            createDirs()
            downloadDat()
            unpackDat()
            installFiles()  
            doCleanup()
    
    if __name__ == "__main__":
        main()
    

    【讨论】:

    • 我不断收到这些错误。回溯(最后一次调用):文件“D:\Script\mcAfee Script2.py”,第 64 行,在 main() 文件“D:\Script\mcAfee Script2.py”,第 57 行,在 main createDirs () 文件“D:\Script\mcAfee Script2.py”,第 35 行,在 createDirs os.chown(tmp, 0, 95) AttributeError: 'module' object has no attribute 'chown'
    • 这个脚本曾经在 Linux 上运行。可能只需要删除 chown 行或找到 Windows 等效项。
    • 感谢您的脚本。我已经通过安装 python 在我的 PC 上进行了测试。但我无法在服务器上安装 python 我必须寻找 powershell 或 vb 脚本。
    • @Lalajee 它是 Python。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 2015-10-23
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多