From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Bart Bunting" Subject: Re: Some advice on how to use babel to generate cisco configs Date: Fri, 01 Feb 2013 19:10:06 +1100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:60316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1E6U-0001De-Qk for emacs-orgmode@gnu.org; Fri, 01 Feb 2013 05:44:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1E6T-0003uF-AA for emacs-orgmode@gnu.org; Fri, 01 Feb 2013 05:44:18 -0500 Received: from 60-240-204-87.tpgi.com.au ([60.240.204.87]:57637 helo=bit.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1E6S-0003tr-Sq for emacs-orgmode@gnu.org; Fri, 01 Feb 2013 05:44:17 -0500 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: emacs-orgmode@gnu.org 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" writes: > Aloha Bart, > "Bart Bunting" 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