shell - Placeholders in bash script for firewall -
i want write function, make:
reading text file in loop
executing command
i have command
for bad_input_ip in `grep -v ^# /etc/rc.d/bad_input.ip`; iptables -i input -s $bad_input_ip -j drop done i want rebuild function:
function go_loop (){ bad_input_ip in `grep -v ^# $1`; iptables -i input -s $bad_input_ip -j drop done } go_loop "/etc/rc.d/bad_input.ip" first part of task made. ok. how make placeholder command ?
iptables -i input -s $bad_input_ip -j drop
i have lot of different commands, need loop. can me ? thanks.
set variable before running going function
function go_loop (){ bad_input_ip in `grep -v ^# $file`; iptables -i input -s $bad_input_ip -j drop done } file="/etc/rc.d/bad_input.ip" go_loop
Comments
Post a Comment