fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] get latest file from remote hosts


From: Carl E. Ma
Subject: [Fab-user] get latest file from remote hosts
Date: Sat, 22 Jun 2013 11:25:52 -0700 (PDT)

Hello,

I need to retrieve the latest log filename from remote host. I was trying to do following:

==
@task
@roles('RemoteHosts')
def RetrieveFile():

    TmpFile =  (sorted(glob.glob('/opt/tomcat/logs/catalina.*'), key=os.path.getmtime))[-1]
    print TmpFile
==

Apparently, this doesn't work as array from glob.glob is always empty.  My workaround is following:

==
@task
@roles('RemoteHosts')
def RetrieveFile():
    TmpFile= run('ls -ct1 /opt/tomcat/logs/catalina.* | head -1')
    print TmpFile
==

It is working fine. But I wonder whether there is other/better solution.

Cheers,

carl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]