Sponsored Content
Top Forums Shell Programming and Scripting Loop to convert text output in the HTML format Post 302964118 by rahul2662 on Monday 11th of January 2016 03:36:29 AM
Old 01-11-2016
Loop to convert text output in the HTML format

Hello Everyone,

I have a sample file raw.txt as shown below :

Code:
Drive Bays

      Bay Name                             :    SD-2C
      Number of Standby Power Supplies     :    4
      Number of Drive Enclosures           :    12

      Summary Status of Contained Modules
        All Enclosures                     :    Normal
        All Link Control Cards             :    Normal
        All Power Supplies                 :    Normal
        All Standby Power Supplies         :    Normal

      Bay Name                             :    SD-2D
      Number of Standby Power Supplies     :    3
      Number of Drive Enclosures           :    16

      Summary Status of Contained Modules
        All Enclosures                     :    Normal
        All Link Control Cards             :    Normal
        All Power Supplies                 :    Normal
        All Standby Power Supplies         :    Normal

      Bay Name                             :    SD-2F
      Number of Standby Power Supplies     :    3
      Number of Drive Enclosures           :    12

      Summary Status of Contained Modules
        All Enclosures                     :    Normal
        All Link Control Cards             :    Normal
        All Power Supplies                 :    Normal
        All Standby Power Supplies         :    Normal

      Bay Name                             :    SD-2G
      Number of Standby Power Supplies     :    6

I want to check for the number of fields ( Field separater is ":") and convert the file contents in HTML format .If there is 1 field (no ":" sign is present for example in case of Drive bays from the file) then
Code:
echo "<tr><td>$arr[0]</td></tr>"

should be printed
where arr[0] is the first field and in case of two fields (for example in case of Bay Name : SD-2C) following should be printed :
Code:
echo "<tr><td>$arr[0]</td><td>$arr[1]</td></tr>"



I tried following to get the number of fields but I am stuck and not getting correct number of fields. Also I got correct number of fields without using :
read -a arr IFS=':' but I have to use this code to create array

Code:
while read line
do
read -a arr IFS=':'
count=`echo "$line" | awk -F":" '{print NF}'`
echo $count
done < raw.txt

Please help

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert comma text file to Column in html format

I am trying to generate a report with below file : File1 : EQADM,edrtere9-phys,8122caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere11-phys,8227caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere3-phys,822caef0,gpatmon,/bin/ksh,nuten Erick can you help me convert it to html and add... (9 Replies)
Discussion started by: sriram003
9 Replies

2. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

3. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

4. Shell Programming and Scripting

Convert TZ output to a different format

Friends, I am trying to convert my local server timezone EST to UTC and for which I used the TZ command, see below $ date Thu Dec 6 10:14:14 EST 2012 $ $ TZ=UTC date -d '10:14 EST' Thu Dec 6 15:14:00 UTC 2012 Now I would like to have the same output in 'yyyymmdd hh:mm' format. ... (4 Replies)
Discussion started by: vivek_damodaran
4 Replies

5. Shell Programming and Scripting

Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html can you please help me output.txt Token State Date1 Date2 Description Name 34567 open 27/06/13 28/06/13 ... (5 Replies)
Discussion started by: vijay_rajni
5 Replies

6. Shell Programming and Scripting

Html output in correct format

Hi, I am running two scripts as below. In Script 1 i am getting correct output in proper HTML format while in script 2 i am not getting output in mail and only html code is getting printed.I want to get the output of script 2. Please guide. 1.IFILE=/home/home01/Report.csv if #Checks... (7 Replies)
Discussion started by: Vivekit82
7 Replies

7. Shell Programming and Scripting

Convert text file to HTML tabular format.

Please provide script/commands to convert text file to HTML tabular format. No need of styles and colours, just output and a heading in table is required. Output file will be send via email and will be seen from outlook. (script required without using awk). output file content: (sar... (7 Replies)
Discussion started by: Veera_V
7 Replies

8. Shell Programming and Scripting

Format text file to html

Hi Experts, Anybody out there figure out on how to achieve in shell scripts or tools. I have done googling to find solutions but no luck. I have thousands of .txt files to batch process, please see the below sample text content after -------- start here --------. What I want to achieve is to... (10 Replies)
Discussion started by: lxdorney
10 Replies

9. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

10. Shell Programming and Scripting

Convert csv data to html format

I am new to html and need to convert the attached csv file data to html format ; running into issues. please assist. #!/bin/ksh echo "<html>" ; echo "<head><style> table {border-collapse: collapse;} table, td, th {border: 1px solid black;} </style></head>" echo "<title> REPORT </title>" echo... (0 Replies)
Discussion started by: archana25
0 Replies
pm-components(9P)					   Kernel Properties for Drivers					 pm-components(9P)

NAME
pm-components - Power Management device property DESCRIPTION
A device is power manageable if the power consumption of the device can be reduced when it is idle. In general, a power manageable device consists of a number of power manageable hardware units called components. Each component is separately controllable and has its own set of power parameters. An example of a one-component power manageable device is a disk whose spindle motor can be stopped to save power when the disk is idle. An example of a two-component power manageable device is a frame buffer card with a connected monitor. The frame buffer electronics (with power that can be reduced when not in use) comprises the first component. The second component is the monitor, which can enter in a lower power mode when not in use. The combination of frame buffer electronics and monitor is considered as one device by the system. In the Power Management framework, all components are considered equal and completely independent of each other. If this is not true for a particular device, the device driver must ensure that undesirable state combinations do not occur. Each component is created in the idle state. The pm-components property describes the Power Management model of a device driver to the Power Management framework. It lists each power manageable component by name and lists the power level supported by each component by numerical value and name. Its syntax and interpreta- tion is described below. This property is only interpreted by the system immediately after the device has successfully attached, or upon the first call into Power Management framework, whichever comes first. Changes in the property made by the driver after the property has been interpreted will not be recognized. pm-components is a string array property. The existence of the pm-components property indicates that a device implements power manageable components and describes the Power Management model implemented by the device driver. The existence of pm-components also indicates to the framework that device is ready for Power Management if automatic device Power Management is enabled. See power.conf(4). The pm-component property syntax is: pm-components="NAME=component name", "numeric power level=power level name", "numeric power level=power level name" [, "numeric power level=power level name" ...] [, "NAME=component name", "numeric power level=power level name", "numeric power level=power level name" [, "numeric power level=power level name"...]...]; The start of each new component is represented by a string consisting of NAME= followed by the name of the component. This should be a short name that a user would recognize, such as "Monitor" or "Spindle Motor." The succeeding elements in the string array must be strings consisting of the numeric value (can be decimal or 0x <hexadecimal number>) of a power level the component supports, followed by an equal sign followed by a short descriptive name for that power level. Again, the names should be descriptive, such as "On," "Off," "Suspend," "Standby," etc. The next component continues the array in the same manner, with a string that starts out NAME=, specifying the beginning of a new component (and its name), followed by specifications of the power levels the component supports. The components must be listed in increasing order according to the component number as interpreted by the driver's power(9E) routine. (Com- ponents are numbered sequentially from 0). The power levels must be listed in increasing order of power consumption. Each component must support at least two power levels, or there is no possiblity of power level transitions. If a power level value of 0 is used, it must be the first one listed for that component. A power level value of 0 has a special meaning (off) to the Power Management framework. EXAMPLES
An example of a pm-components entry from the .conf file of a driver which implements a single power managed component consisting of a disk spindle motor is shown below. This is component 0 and it supports 2 power level, which represent spindle stopped or full speed. pm-components="NAME=Spindle Motor", "0=Stopped", "1=Full Speed"; ... Below is an example of how the above entry would be implemented in the attach(9E) function of the driver. static char *pmcomps[] = { "NAME=Spindle Motor", "0=Stopped", "1=Full Speed" }; ... xxattach(dev_info_t *dip, ddi_attach_cmd_t cmd) { ... if (ddi_prop_update_string_array(DDI_DEV_T_NONE, dip, "pm-components", &pmcomp[0], sizeof (pmcomps) / sizeof (char *)) != DDI_PROP_SUCCESS) goto failed; } Below is an example for a frame buffer which implements two components. Component 0 is the frame buffer electronics which supports four different power levels. Component 1 represents the state of Power Management of the attached monitor. pm-components="NAME=Frame Buffer", "0=Off" "1=Suspend", "2=Standby", "3=On", "NAME=Monitor", "0=Off", "1=Suspend", "2=Standby," "3=On; ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
power.conf(4), pm(7D), attach(9E), detach(9E), ddi_prop_update_string_array(9F) pm_busy_component(9F), pm_idle_component(9F) Writing Device Drivers SunOS 5.10 6 Jan 2004 pm-components(9P)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy