.
Original Message:
Sent: 12-14-2023 20:38
From: YVON LEDUC
Subject: Login scripts
Thanks for your answer Juan.
As a matter of fact, I did thought of a slax script but my result was the XML answer without the headers seen when running the command from the cli. Somehow the copy-of provides those headers. I really don't understand the "magic" of copy-of and why using it, provides the headers as if running the command manually.
If you look at my original request, you will see that I am trying to display only specific lines by piping to find or except. any simple way to do that?
Thanks again for your time.
------------------------------
YVON LEDUC
Original Message:
Sent: 12-14-2023 13:28
From: JUAN RUIZ
Subject: Login scripts
Hi YVON,
Have you thought about an op slax script? You can create one and include both those commands with a separator and have the admins execute an ops command once they login.
Here is an example below with similar commands but not like for like but you should be able to adjust the commands to your supported commands.
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
match / {
<op-script-results> {
var $show_uptime = {
<command> 'show system uptime';
}
var $show_chassis = {
<command> 'show chassis alarm';
}
var $result0 = jcs:invoke($show_uptime);
var $result1 = jcs:invoke($show_chassis);
copy-of $result0;
<output> "_________________________________________________________________________";
copy-of $result1;
}
}
------------------------------
JUAN RUIZ
Original Message:
Sent: 12-13-2023 17:51
From: YVON LEDUC
Subject: Login scripts
Hello all.
I am trying to achieve that when an admin logs in, they would see the result of the following commands:
show system uptime all-members | find user
show virtual-chassis status | except "new member|Chassis" with some blank line to make it pretty !
with the chassis alarms already being shown, this would give me a good indication if somethings is not right about the stack. For example, if a member rebooted or a member is actually down.
I tried creating a first script by putting those commands in it. When I run it, I get the xml stuff without headers. Is there a way to just output the result without having to reinvent the wheel?
On another subject, is scripting a thing of the past? I see examples of scripts from around 2010 that would be interesting to me but they no longer work as the result format changed. But don't see anything recent. Any good location for script examples.
Thanks.
------------------------------
YVON LEDUC
------------------------------