From: "Bart Bunting" <bart@bunting.net.au>
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Some advice on how to use babel to generate cisco configs
Date: Fri, 01 Feb 2013 19:10:06 +1100 [thread overview]
Message-ID: <m2622ccv4x.fsf@ursys.com.au> (raw)
In-Reply-To: <m1k3qtlgp2.fsf@poto.westell.com>
Thomas,
Thanks! That is pretty much what I was struggling with.
Thanks for putting it together for me.
The only other question I have is, is there a way to prevent the results
from appending each time?
Cheers
Bart
"Thomas S. Dye" <tsd@tsdye.com> writes:
> Aloha Bart,
> "Bart Bunting" <bart@bunting.net.au> writes:
>
>> Good morning,
>>
>> I have been trying to figure out without much luck how to use babel to
>> generate some cisco configs.
>>
>>
>> What I would like to achieve is to have a table containing a few values,
>> e.g. ip address vlan number etc.
>>
>> Then have a cisco config in the org file with markers where the
>> substitutions are to be inserted.
>> Run through the table and create a node in the org file one for each row
>> of the table.
>>
>> The end result should be a set of cisco configs with the substitutions
>> made. I was hoping to also use shell to call pwgen to generate a
>> random password to insert.
>>
>> Hope that ramble made some sort of sence.
>
> I don't know a Cisco config from a fig newton, but here is my sense of
> what you wrote, in case it is helpful.
>
> #+name: cisco-table
> | 1 | one | two |
> | 2 | three | four |
> | 3 | five | six |
>
> #+header: :results output raw
> #+header: :var x=cisco-table
> #+begin_src python
> for y in x:
> s = "* Cisco %s \nTwiddle %s, poke %s \n\n" % tuple(y)
> print s,
> #+end_src
>
> #+results:
> * Cisco 1
> Twiddle one, poke two
>
> * Cisco 2
> Twiddle three, poke four
>
> * Cisco 3
> Twiddle five, poke six
>
> --
> Thomas S. Dye
> http://www.tsdye.com
Bart
--
Kind regards
Bart
next prev parent reply other threads:[~2013-02-01 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 22:24 Some advice on how to use babel to generate cisco configs Bart Bunting
2013-01-31 9:50 ` Karl Voit
2013-01-31 11:44 ` Thomas S. Dye
2013-02-01 8:10 ` Bart Bunting [this message]
2013-02-01 15:34 ` Thomas S. Dye
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2622ccv4x.fsf@ursys.com.au \
--to=bart@bunting.net.au \
--cc=emacs-orgmode@gnu.org \
--cc=tsd@tsdye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).