LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 03-05-2021, 02:52 PM   #1
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Rep: Reputation: Disabled
What is the quickest way to get from 1025-65535?


I'm working on something and need this format from 1025-65535 TCP/UDP. Thanks

Code:
192.168.0.12,udp:1024
 
Old 03-05-2021, 03:01 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
You mean something like netstat -atun or ss -atun?

Last edited by shruggy; 03-05-2021 at 03:06 PM.
 
Old 03-05-2021, 03:05 PM   #3
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Original Poster
Rep: Reputation: Disabled
I would like all the ports listed from 1025 to 65535 with every port in between in tcp and udp in the format I posted above.

192.168.0.12,udp:1024
192.168.0.12,tcp:1024
192.168.0.12,udp:1025
192.168.0.12,tcp:1025

etc....

Last edited by PROBLEMCHYLD; 03-05-2021 at 03:06 PM.
 
Old 03-05-2021, 03:11 PM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Code:
awk -F'[ \t/]+' '
  $2>1024&&$3~/^(udp|tcp)$/{print "192.168.0.12,"$3":"$2}
  ' /etc/services
 
Old 03-05-2021, 03:13 PM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
If you mean just a list of them, you could use the following script. If desired, you could redirect the output of the script into a file.

Code:
for i in `seq 1025 65535`; do
  echo "192.168.0.12,udp:$i"
  echo "192.168.0.12,tcp:$i"
done
This was just written off the top of my head without testing... it might need a bit of tweaking.
 
1 members found this post helpful.
Old 03-05-2021, 03:16 PM   #6
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
You need text file ? Stdout ?

First in mind comes a for loop

Code:
for i in [1025-65535]; do echo 198.168.0.12,udp:$i/n198.168.0.12,tcp:$i; done
 
Old 03-05-2021, 03:20 PM   #7
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Tonus View Post
You need text file ? Stdout ?

First in mind comes a for loop

Code:
for i in [1025-65535]; do echo 198.168.0.12,udp:$i/n198.168.0.12,tcp:$i; done
Doesn't this require echo -e to support the newline escape?
 
Old 03-05-2021, 03:26 PM   #8
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
If you mean just a list of them, you could use the following script. If desired, you could redirect the output of the script into a file.

Code:
for i in `seq 1025 65535`; do
  echo "192.168.0.12,udp:$i"
  echo "192.168.0.12,tcp:$i"
done
This was just written off the top of my head without testing... it might need a bit of tweaking.
Seems to work but it doesn't create a log file. Pretty damn fast too.



for i in `seq 1025 65535`; do
echo "192.168.0.12,udp:$i"
echo "192.168.0.12,tcp:$i"
done < /home/problemchyld/Desktop/ports.log
 
Old 03-05-2021, 03:26 PM   #9
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
Doesn't this require echo -e to support the newline escape?
Sure. It does require echo -e, curly braces for brace expansion and backslash escape for \n.

Another option
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/udp/tcp/'
Quote:
Originally Posted by PROBLEMCHYLD View Post
done < /home/problemchyld/Desktop/ports.log
Greater than: >

Last edited by shruggy; 03-05-2021 at 03:28 PM.
 
1 members found this post helpful.
Old 03-05-2021, 03:29 PM   #10
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
Sure. It does require echo -e, curly braces for brace expansion and backslash escape for \n.

Another option
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/udp/tcp/'

Greater than: >
This one liner works too. Thanks but the log file is not listing anything.
 
Old 03-05-2021, 03:30 PM   #11
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Original Poster
Rep: Reputation: Disabled
Thanks shruggy and bass and all who helped. Problem solved.
 
Old 03-05-2021, 03:32 PM   #12
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by PROBLEMCHYLD View Post
the log file is not listing anything.
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/ud/tc/' >/home/problemchyld/Desktop/ports.log

Last edited by shruggy; 03-07-2021 at 08:35 AM.
 
1 members found this post helpful.
  


Reply



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
Whats the quickest/easiest way to get a printable list of all installed software? oldtlhingan Linux - Software 2 05-14-2009 06:42 PM
Quickest way to take a scrshot and crop 'n'save hamster Linux - Software 8 11-13-2007 07:06 AM
Quickest Easist Way to get NTFS support via Fedora Core 2 kevingpo Fedora - Installation 7 12-19-2004 10:02 AM
Quickest way to end Mandrake 9.2 thorman82 Mandriva 3 11-29-2003 10:32 PM
quickest way to upgrade Gnome? asianboi2k Linux - Software 3 10-02-2003 11:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration