It does look better in *nix :-)
C:\>type xmlfile.bat
@echo off
copy NUL xmlfile.xml
for /f %%i% in (input.txt) do (
echo ^<rule^>>> xmlfile.xml
echo ^<type^>block^</type^>>> xmlfile.xml
echo ^<interface^>wan^</interface^>>> xmlfile.xml
echo ^<protocol^>tcp^</protocol^>>> xmlfile.xml
echo ^<source^>>> xmlfile.xml
echo ^<address^>%%i%^</address^>>> xmlfile.xml
echo ^</source^>>> xmlfile.xml
echo ^<destination^>>> xmlfile.xml
echo ^<any/^>>> xmlfile.xml
echo ^</destination^>>> xmlfile.xml
echo ^<descr^>blocked^</descr^>>> xmlfile.xml
echo ^</rule^>>> xmlfile.xml
)
/Roger
On 05/27/11 09:52 PM, Andy Wodfer wrote:
> Thanks for your suggestions! I also got a solution from a friend of mine:
>
> (Unix commands)
>
> File with IP addresses: IP.txt (all files in the same folder)
>
> 1. vi gen.sh
> 2. paste:
>
> #!/bin/sh
>
> while read IP; do
> cat<< EOF
> <rule>
> <type>block</type>
> <interface>wan</interface>
> <protocol>tcp</protocol>
> <source>
> <address>${IP}</address>
> </source>
> <destination>
> <any/>
> </destination>
> <descr>tor</descr>
> </rule>
>
> EOF
>
> 3 write and quit. chmod 755 gen.sh
> 4. cat IP.txt | ./gen.sh> RULES.xml
>
> /Andy
|