fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Writing file with multiple lines to host?


From: Christian Vest Hansen
Subject: Re: [Fab-user] Writing file with multiple lines to host?
Date: Tue, 25 Nov 2008 23:07:42 +0100

On Tue, Nov 25, 2008 at 9:13 PM, Nick Sergeant <address@hidden> wrote:
> I'm trying to create a new file on the remote file system with some
> dynamically generated content, like so:
> run(""" echo "
>         <?php
>         \$db_url =
> 'mysqli://$(new_mysql_user):$(new_mysql_pass)@$(new_mysql_host)/$(new_mysql_db)';
>         \$db_prefix = '';
>         \$update_free_access = FALSE;
>         ini_set('arg_separator.output',     '&amp;');
>         ini_set('magic_quotes_runtime',     0);
>         ini_set('magic_quotes_sybase',      0);
>         ini_set('session.cache_expire',     200000);
>         ini_set('session.cache_limiter',    'none');
>         ini_set('session.cookie_lifetime',  2000000);
>         ini_set('session.gc_maxlifetime',   200000);
>         ini_set('session.save_handler',     'user');
>         ini_set('session.use_only_cookies', 1);
>         ini_set('session.use_trans_sid',    0);
>         ini_set('url_rewriter.tags',        '');
>         \$cookie_domain = '$(new_domain)';
>         " | cat > $(prod_dir)/sites/$(new_domain)/settings.php
>     """)
> However, when the file is written, all of the PHP variable names are
> removed.  Output:
> <?php
> \ = 'mysqli://blogsuser:address@hidden/blogsdomain';
> \ = '';
> \ = FALSE;
> ini_set('arg_separator.output',     '&amp;');
> ini_set('magic_quotes_runtime',     0);
> ini_set('magic_quotes_sybase',      0);
> ini_set('session.cache_expire',     200000);
> ini_set('session.cache_limiter',    'none');
> ini_set('session.cookie_lifetime',  2000000);
> ini_set('session.gc_maxlifetime',   200000);
> ini_set('session.save_handler',     'user');
> ini_set('session.use_only_cookies', 1);
> ini_set('session.use_trans_sid',    0);
> ini_set('url_rewriter.tags',        '');
> \ = 'blogs.domain.com';
> I'm assuming Fabric is thinking those are variables.

Not quite. Notice how the `&amp;` survives.

Fabric is escaping any `$` character that isn't part of a variable, in
an effort to have Bash handle them correctly.

What I think is happening is, that bash is treating them as
environment variable interpolations, but since these variables are not
defined in your environment on the server, they evaluate to the empty
string, thus making it look like they just disappear.

> What would be the best approach to tackle this?  I've tried a bunch of
> alternative methods (using cat, touch, etc), with no luck.

Try playing with the escaping; adding one or two back-slashes, or
removing the one you already have.

I know it's a vague advice, but escaping through multiple layers of
programming and interpretation seems always to be an effort of trial
and error.

> Thanks!
> Nick Sergeant
> www.nicksergeant.com
> address@hidden
> (315) 719-2047
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.




reply via email to

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