LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

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

Rep: Reputation: 0
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.
Code:
MACHINE=8.8.3.201
PORT=2071
exec 3>/dev/tcp/${MACHINE}/${PORT}
if [ $? -eq 0 ]
then
    echo "Port accepting connections"
else
    echo " connections not possible"
fi
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?
Thanks
 
Old 11-05-2012, 07:55 PM   #2
ljb643
Member
 
Registered: Nov 2003
Posts: 282

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, 09:30 AM   #3
zux
Member
 
Registered: Jul 2006
Location: latvia
Distribution: slackware
Posts: 127

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

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

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

Markus
 
Old 11-06-2012, 12:29 PM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,771

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
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.
 
  


Reply


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 07:51 PM
What UNIX command do you use to find out the open ports? ayongying Linux - General 1 05-28-2010 08:46 AM
Cannot Open Mail Server Ports 25, 110, and 220. Other Ports will open. Binxter Linux - Newbie 9 11-29-2007 03:03 AM
How can find out what ports are open in my system linuxlainen Linux - Security 10 08-03-2006 05:05 PM
Find open ports and close them geodo Linux - Newbie 7 11-18-2004 10:33 PM


All times are GMT -5. The time now is 08:28 PM.

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