Hi all

At work, we have a very brain dead system whereby our stores (each of which have a unique 4 digit numerical identifier) connect to port on the main AIX cluster for the purpose of getting the latest prices for trade customers. The silly thing about this system is that sockets are not correctly used and many ports are in use on the AIX cluster where, in a perfect world, only one port should be in use.

I have had to write control scripts(start, stop, monitor in ksh as my Perl is not quite up to the task as yet) for this system. The start script:
- starts the binary and tells it which unique port to listen on (50,000 + store number),
- sleep for 2 seconds (cos it fails otherwise), and
- do a 'ps -ef | grep ...' to see if the binary is still around (they have a habbit of dropping out).

I was thinking today that rather than doing a 'ps -ef | grep ...' it would be better to check and see if anything is listening on that port. There are generally 10,000+ processes at any one time so the ps/grep combination is very slow.

I have no idea how to get a Perl script to see if a port has a program bound to it. So a pointer in that direction would be great.

Thanks
CC


In reply to Excuse me, is that port taken? by coec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.