Find the answer to your Linux question:
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.
  1. #1
    Just Joined!
    Join Date
    Jan 2012
    Posts
    21

    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!!

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    226
    hi,

    see sed's FAQ

  3. #3
    Just Joined!
    Join Date
    Jan 2012
    Posts
    21
    Quote Originally Posted by watael View Post
    hi,

    see sed's FAQ
    Hi
    Thanks but i have already read it and i cant find the answer

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,411
    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.

  6. #5
    Just Joined!
    Join Date
    Jan 2012
    Posts
    21
    Quote Originally Posted by Irithori View Post
    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.
    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!

  7. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,411
    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.

  8. #7
    Just Joined!
    Join Date
    Jan 2012
    Posts
    21
    Quote Originally Posted by Irithori View Post
    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)
    My script locat the OS by opened ports, with Nmap.
    Im searcing for linux unique ports, windows, switches, etc..
    then i entering with ssh/expect/snmp/wmic.

    ohai/facter are any OS compatible or just linux?

  9. #8
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,411
    Have not tested it myself, but at least ohai will run on Windows as well.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •