Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

How Do I find the Port Number For an Internet Service?

by keiusui (Monk)
on Feb 21, 2006 at 06:22 UTC ( #531625=perlquestion: print w/replies, xml ) Need Help??
keiusui has asked for the wisdom of the Perl Monks concerning the following question:

Using a Perl script, how would I find out what port number sendmail uses?

2006-02-22 Retitled by g0n, as per Monastery guidelines
Original title: 'port number'

  • Comment on How Do I find the Port Number For an Internet Service?

Replies are listed 'Best First'.
Re: How Do I find the Port Number For an Internet Service?
by jbrugger (Parson) on Feb 21, 2006 at 06:51 UTC
    monarch is right.
    On your own system you'd could cat /etc/services as root (i'd never do that in a script), but if you've got a proper configured linux like system, certain ports are reserved for proper use, indeed smtp (mail) connects to 25, pop connects to 110 and secure mail connects to 465.
    There are many many more as you probably know. But why do you want to know to how to find out what port number sendmail uses in Perl?

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: How Do I find the Port Number For an Internet Service?
by monarch (Priest) on Feb 21, 2006 at 06:26 UTC
    print `nmap -sS -v -v $hostname` is one way for detecting the port number on a remote system.

    For detecting what is going on in your own system you might want to try print `netstat -ap` and look for what ports sendmail has bound to.

    Assuming you really want to port scan yourself you could try Net::Telnet and try connecting to every port you can and see if you get the introductory SMTP message. Or implement it yourself using IO::Socket::INET.

    Personally I would just try port 25 as a first guess, however.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://531625]
Approved by GrandFather
[1nickt]: Discipulus Yes, I think it is maybe easier to be a good monk in "real" life when you are young and idealistic or old and weary ... nost so much in middle age.
[1nickt]: 😲 ... or did you mean the Middle Ages, when monastic life was more, umm, "earthy" ?!

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-12-13 14:05 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (368 votes). Check out past polls.