I admit I am not the best at writing scripts, I need to write a single file with 2 lines repeated 100 times, 200 lines total, and set 3 variables
$vmid=vm{1..100}
$ip= a single IP from a list (./ip.txt)
$mac= a single MAC from a list (./mac-address.txt)
set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $vmid ip-address $ip
set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $vmid mac-address $mac
So far I can get $vmid set and write the output to a file, but how do I get the other 2 set is where I am hitting a wall
This is what I have tried, but it is putting the entire contents of each list into each line
$vmid=vm{1..100}
$ip= a single IP from a list (./ip.txt)
$mac= a single MAC from a list (./mac-address.txt)
set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $vmid ip-address $ip
set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $vmid mac-address $mac
So far I can get $vmid set and write the output to a file, but how do I get the other 2 set is where I am hitting a wall
This is what I have tried, but it is putting the entire contents of each list into each line
Code:
#!/bin/sh
ip=`cat ./ip.txt`
mac=`cat ./mac-address.txt`
for i in vm{1..100}; do
echo set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $i ip-address $ip >> /root/vyos2
echo set service dhcp-server shared-network-name ETH1_POOL subnet 10.10.10.128/25 static-mapping $i mac-address $mac >> /root/vyos2
done;