Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 11-05-2012, 05:45 PM   #1
Registered: Sep 2012
Posts: 372

Rep: Reputation: 1
Find open ports

Found a script to search for port status open/in-use.
But am unsure of what is happening with the execute command.
exec 3>/dev/tcp/${MACHINE}/${PORT}
if [ $? -eq 0 ]
    echo "Port accepting connections"
    echo " connections not possible"
Does the use of the number 3 have a special meaning?
exec executes files so what is it doing with the 3?
How is that related to /dev/tcp ? Does /dev/tcp require the machine and port ??
Is the dotted quad the local or remote machine address?
Old 11-05-2012, 06:55 PM   #2
Registered: Nov 2003
Posts: 386

Rep: Reputation: Disabled
If you want to check for open ports, I recommend using 'nmap' which is included in Slackware.

If you want to know how the script works, it probably doesn't on Linux (/dev/tcp doesn't exist?). The exec 3>... tells the shell to open a new stream on file descriptor 3 to the named file or device, and continue through the script with the stream open. This use of 'exec' does not execute anything.
Old 11-06-2012, 08:30 AM   #3
Registered: Jul 2006
Location: latvia
Distribution: slackware
Posts: 127

Rep: Reputation: 16
yes, use nmap
simple usage
nmap localhost
nmap -p0-1000 x.x.x.x

Last edited by zux; 11-06-2012 at 08:30 AM. Reason: edit
Old 11-06-2012, 08:57 AM   #4
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
nmap -sV x.x.x.x
where x.x.x.x is your ip adress or hostname.

Old 11-06-2012, 11:29 AM   #5
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,856

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
The example given by the OP uses simple bash commands to check a certain port. It can also be extended to check all possible ports.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] checking for open ports need ports 5198, 5199 open for UDP raypsi Linux - Security 9 05-22-2012 06:51 PM
What UNIX command do you use to find out the open ports? ayongying Linux - General 1 05-28-2010 07:46 AM
Cannot Open Mail Server Ports 25, 110, and 220. Other Ports will open. Binxter Linux - Newbie 9 11-29-2007 02:03 AM
How can find out what ports are open in my system linuxlainen Linux - Security 10 08-03-2006 04:05 PM
Find open ports and close them geodo Linux - Newbie 7 11-18-2004 09:33 PM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration