fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] get latest file from remote hosts


From: Jens Rantil
Subject: Re: [Fab-user] get latest file from remote hosts
Date: Sat, 22 Jun 2013 22:59:07 +0200

Hi Carl,

glob will be executed locally on your
machine.

Your solution is similar to that of mine that I used in one of my scripts. I dont know of any better solution.

Jens

Sent from my iPhone 5S

22 jun 2013 kl. 20:26 skrev "Carl E. Ma" <address@hidden>:

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
_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user

reply via email to

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