I am making a Bash script that randomly generates and then try's to connect to an IP address. I cannot figure out how to make the SSH variable work to connect to the listed IP addresses.
for i in {1..100}
do
STR="printf "%d.%d.%d.%d\n" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))""
done
while true; do
read -p "Start SSH connection? " yn
case $yn in
[Yy]* ) echo ssh $STR; break;;
[Nn]* ) exit;;
* ) echo "Invalid Input";;
esac
done
I tried to assign a variable to the IP generator, so when the user hits yes. It will input the randomly generated Ip addresses. When it runs though, all I get is this: ssh printf %d.%d.%d.%dn 141 138 75 224
Could you please help me?
-CKJones