0

I have wrote a wrapper script to enumerate contents of an 'IP'. The tool works fine,But I wanted to launch multiple requests at a time and get the content.

#Test.sh

#!/usr/bin/env bash
#DATE=$(date +"%Y-%m-%d %H:%M")
#DAY=$(date +"%m_%d")

while IFS=, read -r n a ;do
  OUTPUT=$(./Scanner.sh $a 443 | grep "YES" | sed "s/^\(.\)/$a,\1/")
  echo "$OUTPUT"
done < $1

Run Command : $./Tesh.sh Input.txt

#Input.txt
1,2.2.2.2
2,3.3.3.3
4,10.10.10.10

The output has three fields such as IP,Validation and Enumerated content.

#Output
2.2.2.2,YES,Vulnerable-1
2.2.2.2,YES,Vulnerable-2

Now for each IPs it takes around 30Secs to scan and get the result. I have around 100,000 IPs to get scanned. Is that anything that i can do in my code to launch multiple requests when read from Input.txt and minimize the time ? Thoughts ?

FYI: I'm in bash learning mode.

Arun
  • 1,160
  • 3
  • 17
  • 33
  • As an aside, `grep x | sed 'foo'` is a useless complication; you want `sed -e '/x/!d' -e 'foo'` or in this case simply `sed -n "/YES/s/^\(.\)/$a,\1/p"`. See also [useless use of `grep`](http://www.iki.fi/era/unix/award.html#grep). – tripleee Aug 26 '16 at 07:58
  • Also, capturing output into a variable so that you can `echo` the variable is a useless use of `echo`. Simply don't capture the output, and it will be printed to standard output. – tripleee Aug 26 '16 at 08:02
  • Formatting numbers and measurements as if they were `code` seems rather odd. – tripleee Aug 26 '16 at 08:03

0 Answers0