I have a list of server, and I want to nmap then pass to a Python parser (this)

So normally I do this:

nmap -sV -p- hostname -oN - | python nmaptocsv.py > hostname.txt

Now I want to create a bash script to do this for all lines on a txt file.

So I tried:

#!/usr/bin/bash list="$1" while read -r line ;do echo " processing $line " nmap -sV -p- $line -oN - | python nmaptocsv.py > $line done < "$list"

but this gives me an error on line 5.