Hi Sandeep,

Based on the error message below, it appears that Jens called it.  In your
fabfile.py, you should add some imports and use a task decorator:

*from fabric.api import env, execute, put, require, run, sudo, task, cd*
*import fabric.contrib.files*
*env.hosts=["localhost"]*
*@task*
*def append():*
*        fabric.contrib.files.append("/home/sandeep/fabric/tmp/append",
"test")*
*
*
Note also that fabric.contrib.files.append() only appends the text if it is
not already present in the file.

Regards,
Todd



On Thu, Jun 27, 2013 at 9:29 AM, Sandeep L <sandeepvre...@outlook.com>wrote:

> Hi Todd,
>
> Following is error message:
>
>   File "/usr/lib/python2.7/dist-packages/fabric/main.py", line 674, in main
>     *args, **kwargs
>   File "/usr/lib/python2.7/dist-packages/fabric/tasks.py", line 229, in
> execute
>     task.run(*args, **new_kwargs)
>   File "/usr/lib/python2.7/dist-packages/fabric/tasks.py", line 105, in run
>     return self.wrapped(*args, **kwargs)
>   File "/home/sandeep/fabric/tmp/fabfile.py", line 12, in append
>     fabric.contrib.files.append('/home/sandeep/fabric/tmp/append', 'test')
> NameError: global name 'fabric' is not defined
>
> I am using Fabric 1.3.2 version.
>
> Thanks,
> Sandeep.
>
>
> ------------------------------
> Date: Thu, 27 Jun 2013 07:43:54 -0400
>
> Subject: Re: [Fab-user] Append out to a file in fabfile.py def()
> From: todddel...@gmail.com
> To: sandeepvre...@outlook.com
> CC: fab-user@nongnu.org; andres.rian...@gmail.com
>
>
> Hi Sandeep,
>
> Would you send the error message too?
>
> Regards,
> Todd
>
> Snt frm my tny kbrd
> On Jun 27, 2013 12:51 AM, "Sandeep L" <sandeepvre...@outlook.com> wrote:
>
> Hi Andres,
>
> Fllowing definition I am using and running command "fab append" is
> throwing some errors.
> Can you please correct me if there is any mistake in my definition.
> *
> *
> *env.hosts=["localhost"]*
> *def append():*
> *        fabric.contrib.files.append("/home/sandeep/fabric/tmp/append",
> "test")*
>
>
> Thanks,
> Sandeep.
>
>
> > From: andres.rian...@gmail.com
> > Date: Wed, 26 Jun 2013 09:01:12 -0300
> > Subject: Re: [Fab-user] Append out to a file in fabfile.py def()
> > To: sandeepvre...@outlook.com
> > CC: fab-user@nongnu.org
> >
> >
> http://docs.fabfile.org/en/1.4.0/api/contrib/files.html#fabric.contrib.files.append
> >
> > On Wed, Jun 26, 2013 at 8:58 AM, Sandeep L <sandeepvre...@outlook.com>
> wrote:
> > > Hi,
> > >
> > > I am trying to append some text to a file using a simple definition
> with
> > > fabric.
> > > I tried following definition but not working, can someone please help
> me
> > > resolve this issue.
> > >
> > > def file_append():
> > > run("echo abc >> /home/user/test.txt")
> > >
> > > Also please let me know if there is any other way to achieve this using
> > > fabric.
> > >
> > > Thanks,
> > > Sandeep.
> > >
> > >
> > > _______________________________________________
> > > Fab-user mailing list
> > > Fab-user@nongnu.org
> > > https://lists.nongnu.org/mailman/listinfo/fab-user
> > >
> >
> >
> >
> > --
> > Andrés Riancho
> > Project Leader at w3af - http://w3af.org/
> > Web Application Attack and Audit Framework
> > Twitter: @w3af
> > GPG: 0x93C344F3
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>


-- 
Todd DeLuca
Scientific Programmer
Wall Lab, CBMI, Harvard Medical School
http://todddeluca.com
http://wall.hms.harvard.edu/
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to