Bonjour à tous,
J'utilise aujourd'hui un script de cette forme:
Code Batch : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 @echo off for /f %%a in (liste_pc.txt) do call :Commande %%a :Commande if not exist liste_pc.txt goto:eof set pc=%1 if {%pc%}=={} goto:eof echo host SFx%pc%>> liste_dhcp.txt echo {>>liste_dhcp.txt echo hardware ethernet 00:00:00:00:00:00;>>liste_dhcp.txt echo fixed-address 192.162.100.%pc%;>>liste_dhcp.txt echo }>>liste_dhcp.txt echo host PCx%pc%>> liste_dhcp.txt echo {>>liste_dhcp.txt echo hardware ethernet 00:00:00:00:00:00;>>liste_dhcp.txt echo fixed-address 192.168.200.%pc%;>>liste_dhcp.txt echo }>>liste_dhcp.txt echo.>> liste_dhcp.txt
A coté de cela j'ai un fichier liste_pc.txt comme cela:
11
12
13
14
15
16
17
18
19
Cela me génère un fichier final liste_dhcp.txt ainsi:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 host SFx11 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.11; } host PCx11 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.11; } host SFx12 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.12; } host PCx12 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.12; } host SFx13 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.13; } host PCx13 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.13; } host SFx14 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.14; } host PCx14 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.14; } host SFx15 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.15; } host PCx15 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.15; } host SFx16 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.16; } host PCx16 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.16; } host SFx17 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.17; } host PCx17 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.17; } host SFx18 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.18; } host PCx18 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.18; } host SFx19 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.100.19; } host PCx19 { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.19; }
J'ai besoin de modifier ce script afin d'y incorporer automatiquement un listing de Mac-Adresses mais celui ci serait nommé par exemple liste_mac.txt contenant
Il faudrait que les deux premières MAC soient insérées telle que:00:00:00:00:00:01
00:00:00:00:00:02
.....
puis
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 host SFx11 { hardware ethernet 00:00:00:00:00:01; fixed-address 192.168.100.11; } host PCx11 { hardware ethernet 00:00:00:00:00:02; fixed-address 192.168.200.11; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 host SFx12 { hardware ethernet 00:00:00:00:00:03; fixed-address 192.168.100.12; } host PCx12 { hardware ethernet 00:00:00:00:00:04; fixed-address 192.168.200.12; }
Bien sur toutes ces adresses ne se suivent pas et il faut réellement faire appel aux deux premières valeurs puis au deux secondes ect...
Je suis un peu perdu, auriez vous des pistes ?
Merci d'avance,
Cordialement,
Partager