From: hadi motamedi on
On Jul 23, 9:17 pm, David Kirkby <drkir...(a)gmail.com> wrote:
> I wish to know of a system has a server running at port 8000, and if
> so what its called if possible. I know I can do
>
> $ telnet localhost 8000
>
> but that hangs and one neds to use a control-C, Also, in general, it
> gives no information about that server, though there are exceptions.
>
> I suspect lsof can do this, but that is not a standard part of
> Solaris. (I want to get the information from a script which could be
> run on arbitrary Solairs/OpenSolairs hardware.
>
> Dave

You can use 'nmap' to scan for open ports . The 'nmap -O' will give
you more details about the remote node .
From: David Kirkby on
On Jul 24, 5:36 am, hadi motamedi <motamed...(a)gmail.com> wrote:
> On Jul 23, 9:17 pm, David Kirkby <drkir...(a)gmail.com> wrote:
>
> > I wish to know of a system has a server running at port 8000, and if
> > so what its called if possible. I know I can do
>
> > $ telnet localhost 8000
>
> > but that hangs and one neds to use a control-C, Also, in general, it
> > gives no information about that server, though there are exceptions.
>
> > I suspect lsof can do this, but that is not a standard part of
> > Solaris. (I want to get the information from a script which could be
> > run on arbitrary Solairs/OpenSolairs hardware.
>
> > Dave
>
> You can use 'nmap' to scan for open ports . The 'nmap -O' will give
> you more details about the remote node .

Again, nmap is not a standard command on Solaris. I need to add
something to a script that will interrogate someone elses computer for
debugging purposes. The script will collect information about CPUs,
memory, swap space, hardware etc. But I am particularly interested in
knowing if there is a server at port 8000, as the software (Sage maths
software) will run a server there if the user choses to do so. Knowing
whether that server is there or not would be useful, without programs
like nmap.

Dave
From: David Kirkby on
On Jul 24, 6:59 am, Chris Ridd <chrisr...(a)mac.com> wrote:
> On 2010-07-24 05:17:52 +0100, David Kirkby said:
>
> > I wish to know of a system has a server running at port 8000, and if
> > so what its called if possible. I know I can do
>
> > $ telnet localhost 8000
>
> > but that hangs and one neds to use a control-C, Also, in general, it
> > gives no information about that server, though there are exceptions.
>
> > I suspect lsof can do this, but that is not a standard part of
> > Solaris. (I want to get the information from a script which could be
> > run on arbitrary Solairs/OpenSolairs hardware.
>
> Use "netstat -n", grep the output for "LISTEN" and then your 8000. If
> the port been opened "on all interfaces", it'll look like "*.8000" in
> the output. If it is just open on one interface (eg 1.2.3.4), it'll
> look like 1.2.3.4:8000 instead.
>
> I can't think of an easy way to work out what process has it open. The
> pfiles command can tell you if a given process is listening to a port,
> but you'd need to run it on each running pid...
>
> --
> Chris

That does not appear to work for me on this OpenSolaris machine

drkirkby(a)laptop:~$ netstat -n | grep LISTEN

But I know there is an SSH server on port 22

drkirkby(a)laptop:~$ telnet localhost 22
Trying 127.0.0.1...
Connected to laptop.
Escape character is '^]'.
SSH-2.0-Sun_SSH_1.3

Dave
From: Wolfgang Ley on
Hi,

David Kirkby wrote:
> On Jul 24, 6:59 am, Chris Ridd <chrisr...(a)mac.com> wrote:
>> On 2010-07-24 05:17:52 +0100, David Kirkby said:
>>
>>> I wish to know of a system has a server running at port 8000, and if
>>> so what its called if possible. I know I can do
>>> $ telnet localhost 8000
>>> but that hangs and one neds to use a control-C, Also, in general, it
>>> gives no information about that server, though there are exceptions.
>>> I suspect lsof can do this, but that is not a standard part of
>>> Solaris. (I want to get the information from a script which could be
>>> run on arbitrary Solairs/OpenSolairs hardware.
>> Use "netstat -n", grep the output for "LISTEN" and then your 8000. If
>> the port been opened "on all interfaces", it'll look like "*.8000" in
>> the output. If it is just open on one interface (eg 1.2.3.4), it'll
>> look like 1.2.3.4:8000 instead.
>>
>> I can't think of an easy way to work out what process has it open. The
>> pfiles command can tell you if a given process is listening to a port,
>> but you'd need to run it on each running pid...
>>
>> --
>> Chris
>
> That does not appear to work for me on this OpenSolaris machine
>
> drkirkby(a)laptop:~$ netstat -n | grep LISTEN
>
> But I know there is an SSH server on port 22
>
> drkirkby(a)laptop:~$ telnet localhost 22
> Trying 127.0.0.1...
> Connected to laptop.
> Escape character is '^]'.
> SSH-2.0-Sun_SSH_1.3
>

The "netstat -n" command will only show the active connections but not
the listener. You'll have to use "netstat -an | grep LISTEN" to see the
ports which are ready to accept connections. You'll see 22 there and
you can also check the whether your system offers something on port 8000.

If you do find a port 8000 in LISTEN mode then you'll need to find the
associated application. This can be done by the freeware tool "lsof"
(not included with Solaris) or with the Solaris bundled command
"pfiles", e.g. by using:
# cd /proc; pfiles * > /tmp/pfiles.out
and then check for the port 8000 in that output.

Here is an example output of the sshd listening on port 22:
512: /usr/lib/ssh/sshd
Current rlimit: 256 file descriptors
0: S_IFCHR mode:0666 dev:329,0 ino:6815752 uid:0 gid:3 rdev:13,2
O_RDWR|O_LARGEFILE
/devices/pseudo/mm@0:null
1: S_IFCHR mode:0666 dev:329,0 ino:6815752 uid:0 gid:3 rdev:13,2
O_RDWR|O_LARGEFILE
/devices/pseudo/mm@0:null
2: S_IFCHR mode:0666 dev:329,0 ino:6815752 uid:0 gid:3 rdev:13,2
O_RDWR|O_LARGEFILE
/devices/pseudo/mm@0:null
3: S_IFSOCK mode:0666 dev:336,0 ino:51148 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK
SOCK_STREAM
SO_REUSEADDR,SO_SNDBUF(49152),SO_RCVBUF(49152),IP_NEXTHOP(0.0.192.0)
sockname: AF_INET6 :: port: 22


Bye,
Wolfgang.
From: Chris Ridd on
On 2010-07-24 11:07:06 +0100, Wolfgang Ley said:

> Hi,
>
> David Kirkby wrote:
>> On Jul 24, 6:59 am, Chris Ridd <chrisr...(a)mac.com> wrote:
>>> On 2010-07-24 05:17:52 +0100, David Kirkby said:
>>>
>>>> I wish to know of a system has a server running at port 8000, and if
>>>> so what its called if possible. I know I can do
>>>> $ telnet localhost 8000
>>>> but that hangs and one neds to use a control-C, Also, in general, it
>>>> gives no information about that server, though there are exceptions.
>>>> I suspect lsof can do this, but that is not a standard part of
>>>> Solaris. (I want to get the information from a script which could be
>>>> run on arbitrary Solairs/OpenSolairs hardware.
>>> Use "netstat -n", grep the output for "LISTEN" and then your 8000. If
>>> the port been opened "on all interfaces", it'll look like "*.8000" in
>>> the output. If it is just open on one interface (eg 1.2.3.4), it'll
>>> look like 1.2.3.4:8000 instead.
>>>
>>> I can't think of an easy way to work out what process has it open. The
>>> pfiles command can tell you if a given process is listening to a port,
>>> but you'd need to run it on each running pid...
>>>
>>> --
>>> Chris
>>
>> That does not appear to work for me on this OpenSolaris machine
>>
>> drkirkby(a)laptop:~$ netstat -n | grep LISTEN
>>
>> But I know there is an SSH server on port 22
>>
>> drkirkby(a)laptop:~$ telnet localhost 22
>> Trying 127.0.0.1...
>> Connected to laptop.
>> Escape character is '^]'.
>> SSH-2.0-Sun_SSH_1.3
>>
>
> The "netstat -n" command will only show the active connections but not
> the listener. You'll have to use "netstat -an | grep LISTEN" to see the

Oops. I *always* use -na, I don't know why I said just -n.

--
Chris