fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Fabric "Sed" not preserving the "cd" context


From: B.Nanda Kishore
Subject: [Fab-user] Fabric "Sed" not preserving the "cd" context
Date: Thu, 19 Aug 2010 08:54:28 +0530

Hi All,

I started trying out Fabric just recently and got stuck with Fabric's sed command. The scenario goes like this: I create a django project in a remote machine and I alter some setting in the settings.py file(remotely using Fabric). In this regard I wanted to use Fabric's sed. Here goes the code 

INSTANCE_PARENT_DIRECTORY = '/home/madhavbnk/webapps/django'
INSTANCE_FOLDER_NAME = 'myproject'
PROJECT_BOOTSTRAP_SCRIPT = INSTANCE_PARENT_DIRECTORY + '/' + 'lib/python2.5/django/bin/django-admin.py'

with cd(INSTANCE_PARENT_DIRECTORY):
        run("%s startproject %s" % (PROJECT_BOOTSTRAP_SCRIPT, INSTANCE_FOLDER_NAME))
        with cd(INSTANCE_FOLDER_NAME):
            from fabric.contrib.files import sed
            sed("settings.py", 'address@hidden', 'address@hidden',backup='.backup')

And the error which I get after running this command is:
sed: can't read settings.py: No such file or directory
Warning: run() encountered an error (return code 2) while executing 'sed -i.backup -r -e 's/address@hidden/address@hidden/g' settings.py'

Supposedly, the second "with cd()" should set the context of current working directory and let sed handle the paths corrrectly(relative paths). But its not doing it. It will work if I give the absolute path, which I want to avoid in every step. And infact if I have a command like run("ls") inside the "inner with cd()" , its still listing the settings.py file, still sed is not able to find that.

Please let me know what I am missing and how do I fix this.

Note:This is my first post to the list. Please be kind if I am doing anything wrong.

Regards,
Nandakishore

reply via email to

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