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" <[email protected]>:

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
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to