I am attempting to write a bash loop that passes a bash string into netcat. The command that I execute is:
nc -nv [ipaddress] [port] << EOF
10000
EOF
I am writing a bash loop to perform this and I've tried a number of options. Here's the basic one I've tried that doesn't seem to work:
#!/bin/bash
# declare number
COUNTER=0
END=$(bc <<< -2^10)
while [ $COUNTER -gt $END ]; do
nc -nv [IPADDRESS] [PORT] << $COUNTER
let COUNTER=COUNTER-1
done
<<
operator takes a string and then reads everything until it finds that string again. You need<<EOF\n$COUNTER\nEOF
.<<< "$COUNTER"
rather than trying to use a here document?