How to print the CLI command with the command output

Hello Everyone;

Could you please guide me on how to be able to print the CLI command to the log file?
For example, if I am backing up inventory, and I am using “show chassis hardware”, I would like to see something like this:

ADMIN@ROUTER-BBBJ11.R1.AT> show chassis hardware detail | display xml | no-more



Chassis

Currently, I am only seeing the output and not seeing the hostname with the CLI command.

Here is my script
This my current output. It is not show ing the CLI

. ==> this is my first line

Chassis
JN111F17FAFA

Wondering if anyone has an answer to this :slight_smile:

This is a best effort mailing list run mostly by volunteers. I
wouldn't expect a response in a few hours.

I may be wrong, but given that the purpose of the network modules
(such as the junos ones) is to abstract away the CLI interaction, what
you're asking sounds like the opposite?

Thank you, Dick;

I thought that maybe it should be some kind of option to print the STDIN. In my case, an inventory report without hostnames can not be used.

I then probably should use a python script for this.

Thanks

Can’t you combine the results with another query that returns that hostname?

The first line has to be in this format " ADMIN@ROUTER-BBBJ11.R1.AT> show chassis hardware detail | display xml | no-more ". By the way, there is no DNS working and I am just using IP addresses. I probably use RPC XML and see if I can change the file name to that format then use tail. Or just PyEZ.

Thanks