fab-user
[Top][All Lists]
Advanced

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

Fwd: [Fab-user] How do I search for files remotely using glob.glob?


From: John Keyes
Subject: Fwd: [Fab-user] How do I search for files remotely using glob.glob?
Date: Sat, 25 Sep 2010 00:51:59 +0100

Doh! Didn't cc the list on my reply.

-John

---------- Forwarded message ----------
From: John Keyes <address@hidden>
Date: Fri, Sep 24, 2010 at 11:41 PM
Subject: Re: [Fab-user] How do I search for files remotely using glob.glob?
To: Yungwei Chen <address@hidden>


> I am trying to find a file on the remote machine using glob.glob, but it 
> doesn't do that on the remote machine.
> Do I need to install python 2.6 on the remote machine?
> What am I missing here? Thanks.

Fabric doesn't run on the remote machine, it invokes commands on the
remote machine.

If you want to use glob to find the files, you need to have a python
script on the remote machine that contains your glob code e.g.

#!/bin/python
# /home/yungwei/last_modified.py
last_mod_file = ""
for file in glob.glob("/var/lib/mysql-backup/*"):
   if (file > last_mod_file):
       last_mod_file = file
print last_mod_file,"is the last modified."

Then run that script (provided you already have Python installed on
the remote machine) via fabric.operations.run or
fabric.operations.sudo. For example:

from fabric.operations import run
env.hosts = ['address@hidden']

def print_latest_model():
   run('~/last_modified.py')

(NB: I haven't tested this code, just pointing you in the right direction)

The docs at http://docs.fabfile.org/0.9.2/index.html contain this
information, you should familiarize yourself with them to learn more
about Fabric.

Cheers,
-John



reply via email to

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