Create to HTML from an output of bash script

7,105

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.

Share:
7,105

Related videos on Youtube

Wilfredo Tario
Author by

Wilfredo Tario

Updated on September 18, 2022

Comments

  • Wilfredo Tario
    Wilfredo Tario over 1 year

    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.

    • vatsug
      vatsug over 7 years
      What kind of HTML? Something fancy looking, or just plaintext?