0

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 [email protected] Password: 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.

1
  • What kind of HTML? Something fancy looking, or just plaintext?
    – anaotha
    CommentedFeb 14, 2017 at 14:36

1 Answer 1

2

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.

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.