I want to create a script to convert the output of my script to an HTML format.

Below is the sample output of my script:

[root@test tmp]# cat StoreOnceStatus.txt
spawn ssh -o StrictHostKeyChecking=no storesvc@10.x.x.x
Last login: Fri Jan 27 14:44:50 2017 from 10.x.x.x

Welcome to the HP StoreOnce Backup System Command Line Interface.
Type 'help' at the prompt for context-sensitive help.

> serviceset show status

Service Set 1         Status
-------------         -------
Overall             : Running
StoreOnce Subsystem : Running
Virtual Tape        : Running
NAS                 : Running
StoreOnce Catalyst  : Running
Replication         : Running
Housekeeping        : Running

> hardware show status

Name                  Dev-id                                Status
--------------------  ------------------------------------  ------
HP                    300000000-00000-0000-0000-0000         OK
p0000 Storage System  0000-0000-1000-b0000-50000             OK

> exit

Connection to 10.x.x.x closed.

From that file, I only need to capture and convert to HTML the output of the commands serviceset show status and hardware show status.

  • What kind of HTML? Something fancy looking, or just plaintext? – vatsug Feb 14 '17 at 14:36

You can create template.html file which will be in form that you want. And instead of real values, you fill it with some expressions (for example: SERVICESETSTATUS, HARDWARESTATUS,...) which will later be be replaced with real values that are collected with script.

In script you can use sed command that will replace expression in template with output command:

sed "s/expression/$(command)/" template.html

or in your case:

sed "s/SERVICESETSTATUS/$(serviceset show status)/" template.html

I was using something like this few years back for creating wiki pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.