Automation

last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  printing without newline

    Posted 07-01-2013 18:52
    Looking at the printf man page in Mastering Junos Automation Programming, I don't see a way to suppress a newline. Can jcs:printf or jcs:output print without a newline?


  • 2.  RE: printing without newline

    Posted 07-03-2013 08:13
    Both jcs :output() and append a newline. What are you trying to accomplish? If you want to have multiple text strings appear on the same line, then the best way would be to structure your script so that the text is all written through a single call.


  • 3.  RE: printing without newline

    Posted 07-03-2013 08:28

    Thanks, Curtis. That answers my question.

     

    What I'm trying to do is print interfaces on the same line by cycling through a node-set.

     

    for-each($ns_downstream-interface-names/interface-name) {
         <output> " " _ .;
    }

     

    The number of interfaces is variable so I can't think of any way to use the node-set like an array.

     

    I have to use SLAX 1.0.



  • 4.  RE: printing without newline
    Best Answer

    Posted 07-03-2013 08:34

    Build the string using the for-each loop:

     

    var $interfaces = {

        for-each($ns_downstream-interface-names/interface-name) {

            expr " " _ .;

         }

    }

     

    And then output it:

     

    <output> $interfaces;



  • 5.  RE: printing without newline

    Posted 07-03-2013 08:40

    Thanks! I saw the example using if statements in your book to conditionally assign a variable; however, I didn't realize that a for-each loop could be used to construct a string.