Carl Pender
04-23-2003, 11:59 AM
I have an awk script below that reads in an IP address from a web page. It then matches the IP address with a MAC address and then allows the MAC address onto the network. Here's the script anyway:
#!/bin/bash
read ip_address
sudo arp > /usr/local/apache/logs/users.txt
sudo awk '{if ($1 ==$ip_address) print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
The thing is that this works when I change the $ip_address on the awk line with an actual ip address. e.g.
#!/bin/bash
read ip_address
sudo arp > /usr/local/apache/logs/users.txt
sudo awk '{if ($1 =="123.123.123.123" print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
This will check the arp table for the ip address 123.123.123.123 and then add the corresponding mac address onto the network.
I have also tried putting $ip_address in quotations like so
sudo awk '{if ($1 =="$ip_address") print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
The script add works perfectly so there's no problem there.
Any suggestions guys?
Thanks again
Carl
#!/bin/bash
read ip_address
sudo arp > /usr/local/apache/logs/users.txt
sudo awk '{if ($1 ==$ip_address) print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
The thing is that this works when I change the $ip_address on the awk line with an actual ip address. e.g.
#!/bin/bash
read ip_address
sudo arp > /usr/local/apache/logs/users.txt
sudo awk '{if ($1 =="123.123.123.123" print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
This will check the arp table for the ip address 123.123.123.123 and then add the corresponding mac address onto the network.
I have also tried putting $ip_address in quotations like so
sudo awk '{if ($1 =="$ip_address") print $3}' /usr/local/apache/logs/users.txt | /usr/local/apache/cgi-bin/add
The script add works perfectly so there's no problem there.
Any suggestions guys?
Thanks again
Carl