I wrote about a small automatic vote a year ago.ProgramBecause the website of the other party is limited to one IP address, only 10 votes can be cast per day, so this automatic voting program is mainly used to vote on the proxy server in the initial design stage, later, my colleague provided 30 IP addresses in the LAN.CodeIt's done, but it's really tiring to manually change the IP address in windows, and WMI programming in windows won't. Finally, find a non-FreeBSD machine and write a script, it is configured to run after every day, and the effect is good.
The script name for changing the IP address is cip_vote, which can be called as follows:
./Cipvote fxp0 iptable.txt
In this example, fxp0is the name of the network card. iptable.txt is a list of IP addresses that can be changed. Its format is:
210.77.79.201 255.255.255.128 210.77.79.255
210.77.79.202 255.255.255.128 210.77.79.255
...
The first column is the IP address to be changed, the second column is the subnet mask, and the third column is the broadcast address.
For more information about how to change the IP address, see the ifconfig online manual.Source code:
#! /Usr/local/bin/bash <br/> # first obtain the current IP settings, after the IP address operation is completed, it is restored to the current setting <br/> inet_ip = 'ifconfig $1 | awk '$0 ~ /* Inet */{print $2} ''<br/> inet_netmask = 'ifconfig $1 | awk' $0 ~ /* Inet */{print $4} ''<br/> inet_broadcast = 'ifconfig $1 | awk' $0 ~ /* Inet */{print $6} ''<br/> # Read the file content and set the IP address, netmask, read the broadcast address into the related array and save it <br/> temp = 'wc-L $ 2' <br/> declare-I = 0; <br/> declare-I linenumber = 'echo $ temp | awk '{print $1} ''<br/> declare-I n; <br/> while ["$ I "! = "$ Linenumber"] <br/> DO <br/> N = $ I + 1 <br/> ip_array [N] = 'head-N $2 | tail -N 1 | awk '{print $1} ''<br/> netmask_array [N] = 'head-N $2 | tail-N 1 | awk' {print $2} ''<br/> broadcast_array [N] = 'head-N $2 | tail-N 1 | awk '{print $3}'' <br/> I = $ I + 1 <br/> done <br/> # Use the ifconfig command to change the IP address, then perform the voting, and finally restore the previous IP settings of the host <br/> I = 0; <br/> while ["$ I "! = "$ Linenumber"] <br/> DO <br/> N = $ I + 1 <br/> echo "ifconfig $1 Inet $ {ip_array ['echo $ N' ]} netmask $ {netmask_array ['echo $ n']} broadcast $ {broadcast_array ['echo $ n']} "<br/> ifconfig $1 Inet $ {ip_array [' echo $ n']} netmask $ {netmask_array ['echo $ n']} broadcast $ {broadcast_array ['echo $ n']} <br/> route add default 210.77.79.254 </ p> <p> # Add the code to execute the operation <br/> I = $ I + 1 <br/> done <br/> # restore the code to the original setting. <br/> ifconfig $1 Inet $ inet_ip netmask $ inet_netmask broadcast $ inet_broadcast <br/> route add default 210.77.68.25