shell - Placeholders in bash script for firewall -


i want write function, make:

  1. reading text file in loop

  2. 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

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -