Answer the question
In order to leave comments, you need to log in
Write a simple script?
Good afternoon!
before with scripts in general did not deal.
you need to create the following in a text doc.
for example:
create vlan vlan2
configure vlan vlan2 tag 2
configure vlan vlan2 add ports all
...
create vlan vlan4093
configure vlan vlan4093 tag 4093
configure vlan vlan4093 add ports all
I would like to get a text file as output ...
what methods are there? would like to describe it in more detail...
Answer the question
In order to leave comments, you need to log in
If there is no perl on Windows, then it's easier to make .bat. Something like:
@echo off
set /a "x = 2"
:while1
if %x% leq 4093 (
echo create vlan vlan%x%
echo configure vlan vlan%x% tag %x%
echo configure vlan vlan%x% add ports all
set /a "x = x + 1"
goto :while1
)
#!/bin/bash
for x in $(seq 2 4093)
do
echo "create vlan vlan${x}" >> /tmp/config.txt
echo "configure vlan vlan${x} tag ${x}" >> /tmp/config.txt
echo "configure vlan vlan${x} add ports all" >> /tmp/config.txt
done
Here is a simple script
#!/usr/bin/env bash
# ./scriptname.sh [filename]
# filename не обязательный параметр
# если аргумент был используем его, если нет значение по умолчанию
file=${1:-data.txt}
# если файл есть удаляем
[ -f "$file" ] && rm "$file"
# простой цикл от 2 до 4093 с шагом 1
for i in $(seq 2 4093); do
# дописываем в файл шаблон с переменной
echo "create vlan vlan$i
configure vlan vlan$i tag $i
configure vlan vlan$i add ports all
" >> "$file"
done
#!/urs/bin/perl
# ./script.pl > file.txt
print <<"EOF";
create vlan vlan$1
configure vlan vlan$1 tag $1
configure vlan vlan$1 add ports all
EOF
foreach (2..4093);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question