Results 1 to 8 of 8
Hi
Im writing script that make some inventory to our servers equipment and send the output to HTML template.
Im working with SSH, WMI for windows and Expect to enter ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-02-2013 #1Just Joined!
- Join Date
- Jan 2012
- Posts
- 19
Remove blank lines from script HTML output
Hi
Im writing script that make some inventory to our servers equipment and send the output to HTML template.
Im working with SSH, WMI for windows and Expect to enter to all kind of OS( I need server vendor and serial number) and equipment, at the beginning of each output, im doing nslookup to get device name and then the script printing the output, the problem is that: if the script cant access to devices from some reason(bad password or something) im still get output with devices name from the nslookup command but I didn’t get more details about the device(vendor and serial number).
At the end of the script there is a lot of lines with just name and ip and I want to remove those line with awk/sed or something..
Thats how the output look like (the bold text is the right one and the non-bold Is the text that I want to filter out):
<tr onMouseOver=this.className=highlight onMouseOut=this.className=normal>
<td>192.168.20.13</td>
<td>l-supp-20.labs</td>
<td> Supermicro X9DRH-7TF/7F/iTF/iF </td>
<td> ZAAFWEM00002 </td>
</tr>
<tr onMouseOver=this.className=highlight onMouseOut=this.className=normal>
<td>192.168.20.12</td>
<td>l-supp-21.labs</td>
<td>Supermicro|X9DRH-7TF/7F/iTF/iF|L-SUPP-21</td>
<td>MFJJWXG00001</td>
</tr>
<tr onMouseOver=this.className=highlight onMouseOut=this.className=normal>
<td>192.168.20.3</td>
<td>l-supp-jbod01.labs</td>
<td> Xyratex Thunder I7520 </td>
<td> </td>
</tr>
<tr onMouseOver=this.className=highlight onMouseOut=this.className=normal>
<td>192.168.20.2</td>
<td>l-supp-SX1036-1.labs</td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver=this.className=highlight onMouseOut=this.className=normal>
<td>192.168.20.1</td>
<td>l-supp-SX1016.labs</td>
<td> </td>
<td> </td>
</tr>
Thanks!!
- 02-02-2013 #2Linux Newbie
- Join Date
- Nov 2012
- Posts
- 134
hi,
see sed's FAQ
- 02-03-2013 #3Just Joined!
- Join Date
- Jan 2012
- Posts
- 19
- 02-03-2013 #4
From an architecture point of view it is not optimal to first add something, just to remove it again.
So, as the script is written by you:
Why not just add a check, if the variables for vendor and serial number are empty and if so: Do not output this piece.
Other than that: Are you sure, you need to write your own software for that purpose?
Have a look at facter or ohai, which are part of puppet and chef.
Apart from the fact, that you do not have to maintain self-written code, you could further utilize puppet/chef for install/configuration purposes.You must always face the curtain with a bow.
- 02-03-2013 #5Just Joined!
- Join Date
- Jan 2012
- Posts
- 19
Hi, Thanks for the Answer..
Im trying to maintain self-written code becouse we have a lot of vendor and we didnt find software that doing what we exactly want, and also it fun to write scripts
you right i will foucs on check if the variable is empty, thanks for the Idea..
BTY, great forum i always get answers the myt question here!
- 02-03-2013 #6
I dont know how your script finds out vendor/serial number.
Afaik ohai/facter call dmidecode and evaluate the output.
Also, ohai/facter can be extended.
If you still want to develop your own solution, let me rephrase my suggestion:
Check *all* gathered variables for sanity and emtpyness and react accordingly. (ie: not only for vendor/serial number)You must always face the curtain with a bow.
- 02-03-2013 #7Just Joined!
- Join Date
- Jan 2012
- Posts
- 19
- 02-03-2013 #8
Have not tested it myself, but at least ohai will run on Windows as well.
You must always face the curtain with a bow.


Reply With Quote

