Rex Posted July 26, 2008 Share Posted July 26, 2008 (edited) Hi there... I have a problem i have this list of ip adresses.[autoit]62.12.32.0 - 62.12.63.255 62.44.128.0 - 62.44.191.255 62.61.128.0 - 62.61.159.255 62.66.0.0 - 62.66.127.255 62.66.128.0 - 62.66.255.255 62.79.0.0 - 62.79.255.255 62.107.0.0 - 62.107.255.255 62.116.192.0 - 62.116.223.255 62.121.160.0 - 62.121.191.255 62.135.128.0 - 62.135.255.255 62.182.168.0 - 62.182.175.255 62.182.248.0 - 62.182.255.255 62.198.0.0 - 62.199.255.255 62.242.0.0 - 62.243.255.255 77.66.0.0 - 77.66.127.255 77.68.128.0 - 77.68.255.255 77.72.48.0 - 77.72.55.255 77.75.80.0 - 77.75.87.255 77.75.160.0 - 77.75.167.255 77.212.0.0 - 77.215.255.255 77.221.224.0 - 77.221.255.255 77.233.224.0 - 77.233.255.255 77.234.160.0 - 77.234.191.255 77.242.48.0 - 77.242.63.255 77.243.32.0 - 77.243.47.255 77.243.48.0 - 77.243.63.255 77.243.128.0 - 77.243.143.255 77.244.192.0 - 77.244.207.255 77.247.64.0 - 77.247.79.255 78.31.32.0 - 78.31.39.255 78.109.208.0 - 78.109.223.255 78.111.160.0 - 78.111.175.255 78.143.64.0 - 78.143.127.255 78.153.160.0 - 78.153.191.255 78.156.96.0 - 78.156.127.255 78.157.96.0 - 78.157.127.255 79.98.192.0 - 79.98.199.255 79.142.224.0 - 79.142.239.255 79.170.128.0 - 79.170.135.255 79.171.144.0 - 79.171.151.255 80.62.0.0 - 80.63.255.255 80.67.32.0 - 80.67.47.255 80.71.64.0 - 80.71.95.255 80.72.144.0 - 80.72.159.255 80.77.64.0 - 80.77.79.255 80.80.0.0 - 80.80.15.255 80.80.16.0 - 80.80.31.255 80.82.96.0 - 80.82.111.255 80.88.128.0 - 80.88.143.255 80.88.144.0 - 80.88.159.255 80.89.16.0 - 80.89.31.255 80.91.0.0 - 80.91.15.255 80.91.128.0 - 80.91.143.255 80.160.0.0 - 80.163.255.255 80.164.0.0 - 80.167.255.255 80.196.0.0 - 80.197.255.255 80.198.0.0 - 80.199.255.255 80.208.0.0 - 80.211.255.255 80.233.0.0 - 80.233.127.255 80.243.112.0 - 80.243.127.255 81.7.128.0 - 81.7.191.255 81.19.224.0 - 81.19.239.255 81.19.240.0 - 81.19.255.255 81.31.80.0 - 81.31.95.255 81.95.240.0 - 81.95.255.255 81.161.128.0 - 81.161.191.255 82.103.128.0 - 82.103.191.255 82.143.192.0 - 82.143.255.255 82.147.224.0 - 82.147.255.255 82.150.64.0 - 82.150.95.255 82.180.0.0 - 82.180.255.255 82.192.128.0 - 82.192.159.255 82.192.160.0 - 82.192.191.255 82.211.192.0 - 82.211.223.255 82.211.224.0 - 82.211.255.255 83.72.0.0 - 83.73.255.255 83.74.0.0 - 83.75.255.255 83.88.0.0 - 83.95.255.255 83.97.96.0 - 83.97.103.255 83.136.88.0 - 83.136.95.255 83.137.32.0 - 83.137.39.255 83.143.120.0 - 83.143.127.255 83.151.128.0 - 83.151.191.255 83.221.128.0 - 83.221.159.255 84.16.160.0 - 84.16.191.255 84.234.80.0 - 84.234.95.255 84.238.0.0 - 84.238.127.255 84.246.240.0 - 84.246.247.255 84.255.64.0 - 84.255.127.255 85.24.0.0 - 85.24.127.255 85.27.128.0 - 85.27.255.255 85.80.0.0 - 85.83.255.255 85.89.224.0 - 85.89.255.255 85.129.0.0 - 85.129.127.255 85.202.16.0 - 85.202.31.255 85.202.64.0 - 85.202.79.255 85.218.128.0 - 85.218.255.255 85.233.224.0 - 85.233.255.255 85.235.224.0 - 85.235.255.255 85.236.64.0 - 85.236.95.255 86.48.0.0 - 86.48.255.255 86.52.0.0 - 86.52.255.255 86.58.128.0 - 86.58.255.255 87.48.0.0 - 87.63.255.255 87.72.0.0 - 87.73.255.255 87.104.0.0 - 87.104.255.255 87.116.0.0 - 87.116.63.255 87.238.248.0 - 87.238.255.255 87.239.64.0 - 87.239.71.255 88.83.64.0 - 88.83.95.255 88.151.40.0 - 88.151.47.255 88.212.64.0 - 88.212.127.255 89.19.128.0 - 89.19.159.255 89.104.192.0 - 89.104.223.255 89.150.64.0 - 89.150.127.255 89.150.128.0 - 89.150.191.255 89.184.128.0 - 89.184.159.255 89.186.160.0 - 89.186.191.255 89.221.160.0 - 89.221.175.255 89.233.0.0 - 89.233.63.255 89.239.192.0 - 89.239.255.255 89.249.0.0 - 89.249.15.255 90.184.0.0 - 90.185.255.255 91.100.0.0 - 91.101.255.255 91.102.88.0 - 91.102.95.255 91.143.112.0 - 91.143.127.255 91.144.192.0 - 91.144.255.255 91.150.224.0 - 91.150.255.255 91.189.200.0 - 91.189.207.255 91.190.160.0 - 91.190.167.255 91.192.52.0 - 91.192.55.255 91.192.212.0 - 91.192.215.255 91.193.136.0 - 91.193.139.255 91.194.36.0 - 91.194.37.255 91.194.94.0 - 91.194.95.255 91.194.168.0 - 91.194.169.255 91.195.58.0 - 91.195.59.255 91.196.172.0 - 91.196.175.255 91.197.248.0 - 91.197.251.255 91.198.117.0 - 91.198.117.255 91.198.138.0 - 91.198.138.255 91.198.144.0 - 91.198.144.255 91.198.168.0 - 91.198.168.255 91.198.169.0 - 91.198.169.255 91.198.172.0 - 91.198.172.255 91.198.204.0 - 91.198.204.255 91.198.220.0 - 91.198.220.255 91.198.227.0 - 91.198.227.255 91.198.237.0 - 91.198.237.255 91.198.252.0 - 91.198.252.255 91.199.113.0 - 91.199.113.255 91.199.121.0 - 91.199.121.255 91.199.190.0 - 91.199.190.255 91.199.208.0 - 91.199.208.255 91.199.217.0 - 91.199.217.255 91.206.90.0 - 91.206.91.255 91.208.16.0 - 91.208.16.255 91.208.71.0 - 91.208.71.255 92.43.72.0 - 92.43.79.255 92.43.88.0 - 92.43.95.255 92.43.120.0 - 92.43.127.255 92.43.176.0 - 92.43.183.255 92.43.232.0 - 92.43.239.255 92.60.144.0 - 92.60.159.255 92.62.192.0 - 92.62.207.255 92.243.224.0 - 92.243.255.255 92.246.0.0 - 92.246.31.255 93.90.0.0 - 93.90.15.255 93.90.112.0 - 93.90.127.255 93.95.88.0 - 93.95.95.255 93.160.0.0 - 93.167.255.255 93.176.64.0 - 93.176.127.255 93.178.128.0 - 93.178.191.255 93.184.192.0 - 93.184.207.255 94.18.0.0 - 94.18.255.255 94.144.0.0 - 94.151.255.255 129.142.0.0 - 129.142.255.255 130.227.0.0 - 130.227.255.255 130.228.0.0 - 130.228.255.255 192.38.128.0 - 192.38.255.255 193.0.56.0 - 193.0.60.255 193.0.243.0 - 193.0.243.255 193.3.0.0 - 193.3.255.255 193.9.159.0 - 193.9.159.255 193.16.146.0 - 193.16.146.255 193.17.188.0 - 193.17.188.255 193.17.206.0 - 193.17.206.255 193.23.173.0 - 193.23.173.255 193.23.255.0 - 193.23.255.255 193.26.24.0 - 193.26.24.255 193.26.132.0 - 193.26.132.255 193.26.218.0 - 193.26.218.255 193.27.2.0 - 193.27.2.255 193.27.3.0 - 193.27.3.255 193.27.44.0 - 193.27.44.255 193.27.216.0 - 193.27.217.255 193.27.250.0 - 193.27.251.255 193.28.147.0 - 193.28.147.255 193.28.149.0 - 193.28.149.255 193.28.224.0 - 193.28.224.255 193.28.227.0 - 193.28.227.255 193.29.201.0 - 193.29.201.255 193.31.15.0 - 193.31.15.255 193.33.190.0 - 193.33.191.255 193.39.139.0 - 193.39.139.255 193.41.12.0 - 193.41.13.255 193.41.156.0 - 193.41.157.255 193.41.210.0 - 193.41.211.255 193.43.216.0 - 193.43.217.255 193.46.69.0 - 193.46.69.255 193.46.79.0 - 193.46.79.255 193.47.71.0 - 193.47.71.255 193.47.81.0 - 193.47.81.255 193.47.186.0 - 193.47.186.255 193.47.191.0 - 193.47.191.255 193.84.27.0 - 193.84.27.255 193.88.0.0 - 193.89.255.255 193.108.224.0 - 193.108.225.255 193.109.56.0 - 193.109.57.255 193.109.220.0 - 193.109.220.255 193.110.84.0 - 193.110.84.255 193.110.87.0 - 193.110.87.255 193.110.166.0 - 193.110.167.255 193.110.196.0 - 193.110.199.255 193.138.76.0 - 193.138.76.255 193.138.115.0 - 193.138.115.255 193.138.124.0 - 193.138.124.255 193.142.103.0 - 193.142.103.255 193.142.211.0 - 193.142.211.255 193.149.128.0 - 193.149.191.255 193.162.0.0 - 193.162.255.255 193.163.0.0 - 193.163.255.255 193.164.155.0 - 193.164.155.255 193.164.248.0 - 193.164.251.255 193.186.35.0 - 193.186.35.255 193.189.92.0 - 193.189.93.255 193.200.26.0 - 193.200.26.255 193.200.44.0 - 193.200.45.255 193.200.90.0 - 193.200.91.255 193.200.104.0 - 193.200.105.255 193.200.204.0 - 193.200.204.255 193.200.225.0 - 193.200.225.255 193.200.250.0 - 193.200.250.255 193.201.35.0 - 193.201.35.255 193.201.39.0 - 193.201.39.255 193.201.244.0 - 193.201.247.255 193.219.16.0 - 193.219.27.255 193.219.30.0 - 193.219.30.255 193.221.124.0 - 193.221.124.255 193.223.99.0 - 193.223.99.255 193.238.184.0 - 193.238.187.255 193.239.48.0 - 193.239.51.255 193.239.96.0 - 193.239.99.255 193.239.168.0 - 193.239.169.255 193.239.176.0 - 193.239.177.255 193.242.107.0 - 193.242.107.255 193.243.168.0 - 193.243.175.255 193.254.0.0 - 193.254.0.63 193.254.23.128 - 193.254.23.255 194.0.132.0 - 194.0.132.255 194.0.155.0 - 194.0.155.255 194.0.161.0 - 194.0.161.255 194.0.236.0 - 194.0.236.255 194.1.192.0 - 194.1.192.255 194.1.196.0 - 194.1.196.255 194.1.200.0 - 194.1.200.255 194.19.128.0 - 194.19.191.255 194.19.192.0 - 194.19.223.255 194.29.207.0 - 194.29.207.255 194.30.189.0 - 194.30.189.255 194.42.47.0 - 194.42.47.127 194.42.55.224 - 194.42.55.255 194.50.40.0 - 194.50.40.255 194.50.57.0 - 194.50.57.255 194.50.171.0 - 194.50.171.255 194.50.208.0 - 194.50.208.255 194.63.156.0 - 194.63.159.255 194.88.5.0 - 194.88.5.255 194.105.60.0 - 194.105.60.255 194.110.136.0 - 194.110.136.255 194.110.206.0 - 194.110.206.255 194.116.178.0 - 194.116.179.255 194.116.222.0 - 194.116.223.255 194.117.51.0 - 194.117.51.127 194.117.232.0 - 194.117.233.255 194.126.192.0 - 194.126.192.255 194.126.223.0 - 194.126.223.255 194.126.234.0 - 194.126.234.255 194.126.250.0 - 194.126.250.255 194.140.236.0 - 194.140.236.255 194.149.238.0 - 194.149.239.255 194.150.108.0 - 194.150.111.255 194.152.38.0 - 194.152.39.255 194.153.156.0 - 194.153.156.63 194.165.38.0 - 194.165.38.255 194.165.56.0 - 194.165.56.255 194.169.251.0 - 194.169.251.255 194.176.98.0 - 194.176.98.255 194.176.123.0 - 194.176.123.255 194.182.0.0 - 194.182.127.255 194.182.128.0 - 194.182.143.255 194.182.144.0 - 194.182.151.255 194.182.152.0 - 194.182.159.255 194.182.160.0 - 194.182.191.255 194.182.192.0 - 194.182.223.255 194.182.224.0 - 194.182.231.255 194.182.232.0 - 194.182.239.255 194.182.240.0 - 194.182.255.255 194.192.0.0 - 194.192.255.255 194.239.0.0 - 194.239.63.255 194.239.64.0 - 194.239.127.255 194.239.128.0 - 194.239.255.255 194.242.38.0 - 194.242.38.255 194.242.40.0 - 194.242.40.255 194.242.42.0 - 194.242.42.255 194.242.50.0 - 194.242.50.255 194.255.0.0 - 194.255.255.255 195.5.100.0 - 195.5.101.255 195.7.20.0 - 195.7.31.255 195.10.207.0 - 195.10.207.255 195.13.46.128 - 195.13.46.255 195.14.14.0 - 195.14.14.255 195.22.120.0 - 195.22.123.255 195.24.0.0 - 195.24.31.255 195.24.226.0 - 195.24.227.255 195.24.244.0 - 195.24.245.255 195.41.0.0 - 195.41.255.255 195.42.150.0 - 195.42.151.255 195.47.128.0 - 195.47.191.255 195.47.210.0 - 195.47.210.255 195.47.216.0 - 195.47.216.255 195.47.222.0 - 195.47.222.255 195.47.230.0 - 195.47.230.255 195.47.247.0 - 195.47.247.255 195.50.32.0 - 195.50.63.255 195.54.64.0 - 195.54.95.255 195.60.90.128 - 195.60.90.255 195.60.93.192 - 195.60.93.255 195.60.160.0 - 195.60.161.255 195.64.154.0 - 195.64.155.255 195.66.109.0 - 195.66.109.255 195.69.128.0 - 195.69.131.255 195.69.204.0 - 195.69.207.255 195.74.32.0 - 195.74.35.255 195.74.76.0 - 195.74.76.255 195.74.77.0 - 195.74.77.255 195.80.240.0 - 195.80.255.255 195.82.192.0 - 195.82.223.255 195.85.0.0 - 195.85.127.255 195.85.218.0 - 195.85.218.255 195.85.248.0 - 195.85.248.255 195.85.251.0 - 195.85.251.255 195.85.253.0 - 195.85.253.255 195.90.100.0 - 195.90.101.255 195.93.192.0 - 195.93.193.255 195.95.172.0 - 195.95.172.255 195.95.181.0 - 195.95.181.255 195.95.238.0 - 195.95.243.255 195.95.250.0 - 195.95.251.255 195.97.128.0 - 195.97.191.255 195.110.16.0 - 195.110.17.255 195.128.174.0 - 195.128.175.255 195.135.216.0 - 195.135.219.255 195.135.228.0 - 195.135.231.255 195.137.178.0 - 195.137.178.255 195.137.183.0 - 195.137.183.255 195.137.194.0 - 195.137.195.255 195.137.236.0 - 195.137.237.255 195.140.132.0 - 195.140.135.255 195.149.78.0 - 195.149.78.255 195.158.242.0 - 195.158.243.255 195.181.0.0 - 195.181.31.255 195.181.32.0 - 195.181.63.255 195.181.64.0 - 195.181.127.255 195.181.128.0 - 195.181.255.255 195.182.32.0 - 195.182.32.255 195.182.36.0 - 195.182.36.255 195.182.39.0 - 195.182.39.255 195.182.204.0 - 195.182.205.255 195.182.216.0 - 195.182.217.255 195.184.32.0 - 195.184.63.255 195.184.96.0 - 195.184.127.255 195.189.130.0 - 195.189.131.255 195.189.232.0 - 195.189.233.255 195.190.18.0 - 195.190.18.255 195.190.25.0 - 195.190.25.255 195.190.30.0 - 195.190.30.255 195.190.31.0 - 195.190.31.255 195.190.128.0 - 195.190.128.255 195.190.146.0 - 195.190.146.255 195.190.149.0 - 195.190.149.255 195.190.153.0 - 195.190.153.255 195.192.0.0 - 195.192.255.255 195.215.0.0 - 195.215.255.255 195.216.253.0 - 195.216.253.255 195.225.88.0 - 195.225.91.255 195.231.0.0 - 195.231.255.255 195.234.0.0 - 195.234.31.255 195.234.155.0 - 195.234.155.255 195.234.160.0 - 195.234.160.255 195.242.120.0 - 195.242.121.255 195.242.130.0 - 195.242.131.255 195.242.192.0 - 195.242.195.255 195.245.72.0 - 195.245.73.255 195.245.193.0 - 195.245.193.255 195.245.207.0 - 195.245.207.255 195.245.210.0 - 195.245.210.255 195.246.198.0 - 195.246.198.255 195.249.0.0 - 195.249.255.255 212.10.0.0 - 212.10.31.255 212.10.32.0 - 212.10.63.255 212.10.64.0 - 212.10.127.255 212.10.128.0 - 212.10.255.255 212.37.128.0 - 212.37.159.255 212.54.64.0 - 212.54.95.255 212.60.96.0 - 212.60.127.255 212.70.0.0 - 212.70.31.255 212.88.64.0 - 212.88.95.255 212.93.32.0 - 212.93.63.255 212.97.128.0 - 212.97.159.255 212.97.192.0 - 212.97.223.255 212.97.224.0 - 212.97.255.255 212.98.64.0 - 212.98.127.255 212.99.224.0 - 212.99.255.255 212.112.128.0 - 212.112.159.255 212.130.0.0 - 212.130.255.255 212.237.0.0 - 212.237.255.255 212.242.0.0 - 212.242.127.255 212.242.128.0 - 212.242.255.255 213.32.0.0 - 213.32.255.255 213.83.128.0 - 213.83.255.255 213.129.0.0 - 213.129.31.255 213.132.0.0 - 213.132.31.255 213.150.32.0 - 213.150.63.255 213.170.224.0 - 213.170.255.255 213.173.224.0 - 213.173.255.255 213.174.64.0 - 213.174.95.255 213.237.0.0 - 213.237.63.255 213.237.64.0 - 213.237.127.255 213.237.128.0 - 213.237.191.255 217.10.16.0 - 217.10.31.255 217.16.96.0 - 217.16.111.255 217.20.48.0 - 217.20.63.255 217.20.64.0 - 217.20.79.255 217.23.96.0 - 217.23.111.255 217.28.160.0 - 217.28.175.255 217.30.80.0 - 217.30.95.255 217.60.0.0 - 217.61.255.255 217.74.208.0 - 217.74.223.255 217.116.224.0 - 217.116.239.255 217.116.240.0 - 217.116.255.255 217.145.48.0 - 217.145.63.255 217.157.0.0 - 217.157.255.255 217.195.176.0 - 217.195.191.255 217.198.208.0 - 217.198.223.255 Edited July 27, 2008 by SmOke_N Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 27, 2008 Moderators Share Posted July 27, 2008 What is a "complete" list look like? lol... Do you have an example output of at least one of them? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
=sinister= Posted July 27, 2008 Share Posted July 27, 2008 #include <file.au3> $File = FileOpen("./test.txt", 1) $Lines = _FileCountLines("./test.txt") $Count = 1 _FileCreate("./NewOutput.txt") While $Count < $Lines $Read = FileReadLine("./test.txt", $Count) $Split = StringSplit($Read, " - ", 1) FileWriteLine("./NewOutput.txt", $Split[1]) FileWriteLine("./NewOutput.txt", $Split[2]) $Count = $Count + 1 WEnd FileClose($File) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 27, 2008 Moderators Share Posted July 27, 2008 #include <file.au3> $File = FileOpen("./test.txt", 1) $Lines = _FileCountLines("./test.txt") $Count = 1 _FileCreate("./NewOutput.txt") While $Count < $Lines $Read = FileReadLine("./test.txt", $Count) $Split = StringSplit($Read, " - ", 1) FileWriteLine("./NewOutput.txt", $Split[1]) FileWriteLine("./NewOutput.txt", $Split[2]) $Count = $Count + 1 WEnd FileClose($File)And how exactly does that go in succession? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nevin Posted July 27, 2008 Share Posted July 27, 2008 I'm fairly drunk, and wandering forums. Uhh. A complete list, I believe he means each address in the range. so if your range was 62.0.1.0 to 62.1.2.0 it would be like 62.0.1.0 62.0.1.1 62.0.1.2 62.0.1.3 -omitted- 62.0.1.255 62.0.2.0 62.0.2.1 62.0.2.2 ...blah. very long. I don't think this is the time I should be helping. ha. It sounds like the solution would probably involve seperately incrementing each octet and then concatenating results. messy crap, lots to write for someone like me. especially for free. Link to comment Share on other sites More sharing options...
=sinister= Posted July 27, 2008 Share Posted July 27, 2008 oh, well it all depends on what he means, he needs to be more specific. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 27, 2008 Moderators Share Posted July 27, 2008 This is what I assume he wants... however, look how deep the loops can go, which can only mean there is no way in hell this will be fast with that large of a file. It took me almost 20 mins to do the file. It went from a 14kb text file, to a 130 mb file lol... _IPRange("test.txt", "test.log") ;We assume the list is from least to greatest ;There are 4 parts to the ip, so we have to break it up into 4 parts Func _IPRange($s_in_file, $s_out_file, $s_delim = ",") If FileExists($s_in_file) = 0 Then Return SetError(1, 0, 0) Local $s_string = FileRead($s_in_file) Local $a_ip1 = StringRegExp($s_string, "(?s)(?:^|\n)(\d+)\.(\d+)\.(\d+)\.(\d+)\s*-", 3) Local $a_ip2 = StringRegExp($s_string, "(?s)-\s+(\d+)\.(\d+)\.(\d+)\.(\d+)\s*(?:\z|\r)", 3) Local $n_ub1 = UBound($a_ip1) - 1, $n_ub2 = UBound($a_ip2) - 1 If $n_ub1 <> $n_ub2 Then Return SetError(2, 0, 0) Local $i_1, $i_2, $i_3, $i_4, $s_out For $i = 0 To $n_ub1 Step 4 For $i_1 = $a_ip1[$i] To $a_ip2[$i] For $i_2 = $a_ip1[$i + 1] To $a_ip2[$i + 1] For $i_3 = $a_ip1[$i + 2] To $a_ip2[$i + 2] For $i_4 = $a_ip1[$i + 3] To $a_ip2[$i + 3] $s_out &= $i_1 & "." & $i_2 & "." & $i_3 & "." & $i_4 & "." & $s_delim Next Next Next Next $s_out = StringTrimRight($s_out, StringLen($s_delim)) & @CRLF Next $s_out = StringTrimRight($s_out, 2) FileClose(FileOpen($s_out_file, 2)) Return FileWrite($s_out_file, $s_out) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Rex Posted July 27, 2008 Author Share Posted July 27, 2008 This is what I assume he wants... however, look how deep the loops can go, which can only mean there is no way in hell this will be fast with that large of a file. It took me almost 20 mins to do the file. It went from a 14kb text file, to a 130 mb file lol... _IPRange("test.txt", "test.log") ;We assume the list is from least to greatest ;There are 4 parts to the ip, so we have to break it up into 4 parts Func _IPRange($s_in_file, $s_out_file, $s_delim = ",") If FileExists($s_in_file) = 0 Then Return SetError(1, 0, 0) Local $s_string = FileRead($s_in_file) Local $a_ip1 = StringRegExp($s_string, "(?s)(?:^|\n)(\d+)\.(\d+)\.(\d+)\.(\d+)\s*-", 3) Local $a_ip2 = StringRegExp($s_string, "(?s)-\s+(\d+)\.(\d+)\.(\d+)\.(\d+)\s*(?:\z|\r)", 3) Local $n_ub1 = UBound($a_ip1) - 1, $n_ub2 = UBound($a_ip2) - 1 If $n_ub1 <> $n_ub2 Then Return SetError(2, 0, 0) Local $i_1, $i_2, $i_3, $i_4, $s_out For $i = 0 To $n_ub1 Step 4 For $i_1 = $a_ip1[$i] To $a_ip2[$i] For $i_2 = $a_ip1[$i + 1] To $a_ip2[$i + 1] For $i_3 = $a_ip1[$i + 2] To $a_ip2[$i + 2] For $i_4 = $a_ip1[$i + 3] To $a_ip2[$i + 3] $s_out &= $i_1 & "." & $i_2 & "." & $i_3 & "." & $i_4 & "." & $s_delim Next Next Next Next $s_out = StringTrimRight($s_out, StringLen($s_delim)) & @CRLF Next $s_out = StringTrimRight($s_out, 2) FileClose(FileOpen($s_out_file, 2)) Return FileWrite($s_out_file, $s_out) EndFuncI could newer have don that. , but when i try to use it on the complete list i get a memory error. And yes it will generate a werrrrrrry big list :P, i needed it to generate an allow only from list to my ftp server - so only some one from denmark was allowed to access my ftp... Well back to the drawing board.. But but really really many thx for this script i could newer have done that with out help. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 27, 2008 Moderators Share Posted July 27, 2008 (edited) I could newer have don that. , but when i try to use it on the complete list i get a memory error. And yes it will generate a werrrrrrry big list :P, i needed it to generate an allow only from list to my ftp server - so only some one from denmark was allowed to access my ftp... Well back to the drawing board.. But but really really many thx for this script i could newer have done that with out help.Yeah, the memory issue is going to be a big deal... here's a suggestion to keep it from being one:_IPRange("test.txt", "test.log") ;We assume the list is from least to greatest ;There are 4 parts to the ip, so we have to break it up into 4 parts Func _IPRange($s_in_file, $s_out_file, $s_delim = ",") If FileExists($s_in_file) = 0 Then Return SetError(1, 0, 0) Local $s_string = FileRead($s_in_file) Local $a_ip1 = StringRegExp($s_string, "(?s)(?:^|\n)(\d+)\.(\d+)\.(\d+)\.(\d+)\s*-", 3) Local $a_ip2 = StringRegExp($s_string, "(?s)-\s+(\d+)\.(\d+)\.(\d+)\.(\d+)\s*(?:\z|\r)", 3) Local $n_ub1 = UBound($a_ip1) - 1, $n_ub2 = UBound($a_ip2) - 1 If $n_ub1 <> $n_ub2 Then Return SetError(2, 0, 0) Local $i_1, $i_2, $i_3, $i_4, $s_out FileClose(FileOpen($s_out_file, 2)) For $i = 0 To $n_ub1 Step 4 For $i_1 = $a_ip1[$i] To $a_ip2[$i] For $i_2 = $a_ip1[$i + 1] To $a_ip2[$i + 1] For $i_3 = $a_ip1[$i + 2] To $a_ip2[$i + 2] For $i_4 = $a_ip1[$i + 3] To $a_ip2[$i + 3] $s_out &= $i_1 & "." & $i_2 & "." & $i_3 & "." & $i_4 & $s_delim Next Next Next Next $s_out = StringTrimRight($s_out, StringLen($s_delim)) & @CRLF FileWrite($s_out_file, $s_out) $s_out = "" Next Return 1 EndFuncI'm not a fan of writing to a file from within a loop, but holding and adding to a 150 mb file can only slow the process down even more. This method should prove to be 10x's faster at least with far less memory impact. Edit: There was a mistake in the code, there was 1 too many decimals in the output... it only took 2.7 minutes this time versus 20 mins. Edited July 27, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now