[j-nsp] sequential commands in SLAX

Martin T m4rtntns at gmail.com
Thu Jan 14 09:02:31 EST 2016


Wojciech,

I didn't know that, thanks! However, I also tried with jcs:open(),
jcs:execute() and jcs:close() but this didn't change anything:


$ cat login_to_other_re.slax
version 1.0;

ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";

match / {
  <op-script-results> {

    /* open local management session */
    var $connection = jcs:open();

    /* rlogin to second RE */
    var $cmd_login_other_re = <command> "request routing-engine login
other-routing-engine";
    var $cmd_login_other_re_results = jcs:execute( $connection,
$cmd_login_other_re );

    /* print out the name of the second RE */
    <output> $junos-context//routing-engine-name;

    /* exit rlogin session */
    var $cmd_quit_other_re = <command> "quit";
    var $cmd_quit_other_re_results = jcs:execute( $connection,
$cmd_quit_other_re );

    /* close management session */
    expr jcs:close( $connection );

  }
}
$

thanks,
Martin

On 1/14/16, Wojciech Janiszewski <wojciech.janiszewski at gmail.com> wrote:
> Hi Martin,
>
> I believe that jcs:invoke() is just a shortcut for jcs:open(),
> jcs:execute() and jcs:close(), so you get a new connection each time you
> execute jcs:invoke().
>
> Regards,
> Wojciech
>
> 2016-01-14 10:23 GMT+01:00 Martin T <m4rtntns at gmail.com>:
>
>> Hi,
>>
>> while I am aware of jcs:open() function, which allows one to execute
>> commands on other routing-engine, I was wondering if following logic
>> is also possible in SLAX:
>>
>> $ cat login_to_other_re.slax
>> version 1.0;
>>
>> ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
>> import "../import/junos.xsl";
>>
>> match / {
>>   <op-script-results> {
>>
>>     /* rlogin to second RE */
>>     var $cmd_login_other_re = <command> "request routing-engine login
>> other-routing-engine";
>>     var $cmd_login_other_re_results = jcs:invoke( $cmd_login_other_re );
>>
>>     /* print out the name of the second RE */
>>     <output> $junos-context//routing-engine-name;
>>
>>     /* exit rlogin session */
>>     var $cmd_quit_other_re = <command> "quit";
>>     var $cmd_quit_other_re_results = jcs:invoke( $cmd_quit_other_re );
>>
>>   }
>> }
>> $
>>
>>
>> Why doesn't such approach work?
>>
>>
>> thanks,
>> Martin
>> _______________________________________________
>> juniper-nsp mailing list juniper-nsp at puck.nether.net
>> https://puck.nether.net/mailman/listinfo/juniper-nsp
>>
>


More information about the juniper-nsp mailing list