<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: netstat script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122063#M495973</link>
    <description>&lt;P&gt;Ahh...In this case you would have to use something like Expect to write your script. &amp;nbsp;You can have conditions in Expect so that should allow you to try different passwords.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have any examples of an Expect script. &amp;nbsp;Perhaps some of the other folks here.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2013 21:25:41 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2013-07-01T21:25:41Z</dc:date>
    <item>
      <title>netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122005#M495970</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a script which will do netstat into all servers listed on a file and create a list with server names and all established port details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or in other way, a script to login to all servers and capture the o/p of 'netstat -avtn |grep -i established' in single file with server names&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2013 20:09:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122005#M495970</guid>
      <dc:creator>Ku</dc:creator>
      <dc:date>2013-07-01T20:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122013#M495971</link>
      <description>&lt;P&gt;Do you have SSH set up so that you can log into each server without providing a password? &amp;nbsp;If not, that is the first step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you do have SSH set up for passwordless logins, then something like this ought to get you started:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# netstat-script.sh&lt;/P&gt;&lt;P&gt;#!/usr/bin/sh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for SERV in $(&amp;lt; /dir/list-of-servers)&lt;/P&gt;&lt;P&gt;do&lt;/P&gt;&lt;P&gt;echo ${SERV}&lt;/P&gt;&lt;P&gt;ssh ${SERV} "&lt;SPAN&gt;netstat -avn |grep -i established"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;echo ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;done &amp;gt; /dir/netstat-script.out&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I remove the 't' option from your netstat command as that is not a valid option on HP-UX.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Your file with the list of servers in it should have one server name per line.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# cat list-of-servers&lt;BR /&gt;atl1&lt;BR /&gt;atl2&lt;BR /&gt;atl3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will also need to modify the directory names and file names to suit you, but this should get you started.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2013 20:19:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122013#M495971</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2013-07-01T20:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122019#M495972</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply.. Issue is I dont have passowrdless ssh in place.&amp;nbsp; Also I dont have single password on all servers. i have around 3 different root passwords on different serevrs. So is there any way that I can put all these three password in one file and have the script to read that one by one.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2013 20:26:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122019#M495972</guid>
      <dc:creator>Ku</dc:creator>
      <dc:date>2013-07-01T20:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122063#M495973</link>
      <description>&lt;P&gt;Ahh...In this case you would have to use something like Expect to write your script. &amp;nbsp;You can have conditions in Expect so that should allow you to try different passwords.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have any examples of an Expect script. &amp;nbsp;Perhaps some of the other folks here.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2013 21:25:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122063#M495973</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2013-07-01T21:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122985#M495974</link>
      <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;should have one server name per line.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually with $(&amp;lt; file), you don't need them one per line.&lt;/P&gt;&lt;P&gt;But if you ever want to switch to "while read server" you would.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2013 16:11:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6122985#M495974</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-07-02T16:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: netstat script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6123365#M495975</link>
      <description>&lt;P&gt;When you don't have a single method to transfer files (ssh is very powerful for this purpose), I use batch ftp rather than Expect. Expect can be a challenge to install and use, whereas ftp can be controlled with a simple 'here document' &amp;nbsp;with the appropriate commands (including open, user and password).&lt;BR /&gt;&lt;BR /&gt;Here's a simple example. Because these commands can be assigned to a variable, you can design your netstat gathering script to capture your data in a local file on each server and then transfer it to your central server on request or perhaps by cron. This is for a one time copy. Each run will overlay the previous run's file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/sh
set -u
# Script to capture netstat/established data
# Customize with USER, PW for the collector system
# Local file is stored in the same location at the collector

LOGIN=guest
PW=guest1234
COLLECTOR=server1

MYHOST=$(hostname)
TEMPFILE=/tmp/$MYHOST-netstat.tmp
DATESTAMP=$(date '+%Y-%m%d')
echo "$MYHOST - $DATESTAMP\n$(netstat -avn |
     grep -i established)" &amp;gt; $TEMPFILE

ftp -n -v $COLECTOR &amp;lt;&amp;lt; EOF
  user $LOGIN $PW
  ascii
  put $TEMPFILE $TEMPFILE
  chmod 600 $TEMPFILE
  bye
EOF

rm -f $TEMPFILE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By having the script run on each server, no login/password list is needed. And since netstat can be run by any user, there is much better security by creating an ordinary user to run the script on each system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2013 00:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/netstat-script/m-p/6123365#M495975</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2013-07-03T00:39:07Z</dc:date>
    </item>
  </channel>
</rss>

