Automation

 View Only
last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Commands Iteration for Slax Script

    Posted 30 days ago

    Hello Everyone,

    Is it possible to iterate the value of commands in a LSLAX script?

    For example, using python.

    commands = [ command1, command2, command3]

    for command in commands:

    I have a series of shell commands and I want to iterate it.

    var $vty-command = {

         <request-shell-execute> {

                      <command> command1;

                       <command> command2; 

    and so on..

    Thank you in advance.



    ------------------------------
    Gerald
    ------------------------------


  • 2.  RE: Commands Iteration for Slax Script

     
    Posted 30 days ago
    Edited by asharp 30 days ago

    Sure, you can do something similar with SLAX.

    version 1.2;
    
    main <op-script-results> {
        <output> {
            var $commands := {
                <command> "command1";
                <command> "command2";
                <command> "command3";
                <command> "command4";
            }
            expr "\n";
            for-each ( $commands/command ) {
                /* do stuff */
                expr "Command: " _ . _ "\n";
            }
        }
    }
    
    Results:
    juise iterate.slax
    
    <?xml version="1.0"?>
    <op-script-results><output>
    Command: command1
    Command: command2
    Command: command3
    Command: command4
    </output></op-script-results>
    



    ------------------------------
    Andy Sharp
    ------------------------------