none
AJUDA COM SCRIPT TXT RRS feed

  • Pergunta

  • Olá gostaria de saber se alguem pode me ajudar?
    queria eu fazer um script que me retornase um arquivo txt com as seguintes linhas

    no caso o script me pediria a faixa de IP e a interface e o resto ele faria altomaticamente
    no caso as 64 linhas pulando de 4 em 4...

    add address=172.150.20.1/30 network=172.150.20.0 broadcast=172.150.20.3 interface="eth0" comment="" disabled=no
    add address=172.150.20.5/30 network=172.150.20.4 broadcast=172.150.20.7 interface="eth0" comment="" disabled=no
    add address=172.150.20.9/30 network=172.150.20.8 broadcast=172.150.20.11 interface="eth0" comment="" disabled=no
    e assim por diante até chegar ao final da faixa de ip no caso 254...

    obrigado!!!
    NETWAR TEAM
    sexta-feira, 15 de maio de 2009 18:39

Respostas

  • Olá,

    Veja se é isso que você precisa:

    strFileName = "script.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")

    strIP = InputBox("Faixa IP" & vbCrLf & "Exemplo: 172.150.20" , , "172.150.20")
    strMASK = InputBox("Bits da Mascara" & vbCrLf & "Exemplo: 30" , , "30")
    strInterface = InputBox("Interface" & vbCrLf & "Exemplo: eth0" , , "eth0")
    strPulo = InputBox("Pular ips " & vbCrLf & "Exemplo: 3" , , "3")
    strQuantidade = InputBox("Quantidade de rota " & vbCrLf & "Exemplo: 64" , , "64")

    if strIP <> "" Then
       Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)

       objTextStream.WriteLine "/ip address"
       i = 1
       For x = 1 to strQuantidade
          objTextStream.WriteLine "add address=" & strIP & "." & i & "/" & strMask & " interface=" & strInterface
          i = i + strPulo
       Next
       objTextStream.Close
    End if


    Faça os testes e nos retorne.

    Até mais,

    Jesiel

    Obs.: Se útil, classifique
    segunda-feira, 18 de maio de 2009 17:35

Todas as Respostas

  • comecei algo deem uma olhada...

    #############################################################################

    strFileName = "script.txt"

    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)
    objTextStream.WriteLine "/ip address"
    objTextStream.WriteLine "add address=172.150.20.1/30 interface=eth0"
    objTextStream.WriteLine "add address=172.150.20.4/30 interface=eth0"
    objTextStream.WriteLine "add address=172.150.20.9/30 interface=eth0" 

    #############################################################################

    agora preciso de ajuda pra saber como fazer pro script me pedir o
    address(faixa de ip), o barramento(24, 28, 30, etc...) e a interface
    e fazer o restante das linhas altomaticamente?


    NETWAR TEAM
    domingo, 17 de maio de 2009 18:10
  • Olá,

    Veja se é isso que você precisa:

    strFileName = "script.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")

    strIP = InputBox("Faixa IP" & vbCrLf & "Exemplo: 172.150.20" , , "172.150.20")
    strMASK = InputBox("Bits da Mascara" & vbCrLf & "Exemplo: 30" , , "30")
    strInterface = InputBox("Interface" & vbCrLf & "Exemplo: eth0" , , "eth0")
    strPulo = InputBox("Pular ips " & vbCrLf & "Exemplo: 3" , , "3")
    strQuantidade = InputBox("Quantidade de rota " & vbCrLf & "Exemplo: 64" , , "64")

    if strIP <> "" Then
       Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)

       objTextStream.WriteLine "/ip address"
       i = 1
       For x = 1 to strQuantidade
          objTextStream.WriteLine "add address=" & strIP & "." & i & "/" & strMask & " interface=" & strInterface
          i = i + strPulo
       Next
       objTextStream.Close
    End if


    Faça os testes e nos retorne.

    Até mais,

    Jesiel

    Obs.: Se útil, classifique
    segunda-feira, 18 de maio de 2009 17:35
  • OK era bem o que eu precisava
    fiz umas alterações e preciso de mais uma ajuda veja....

    strFileName = "script.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")

    strIP = InputBox("ATENÇÃO!!!" & vbCrLf & "" & vbCrlf & "Qual é a classe de IP que você deseja usar" & vbCrLf & "" & vbCrLf & "ex: 192.168.0." , , "192.168.0.")
    strInterface = InputBox("ATENÇÃO!!!" & vbCrLf & "" & vbCrlf & "Qual é a Interface que você deseja usar" & vbCrLf & "" & vbCrLf & "ex: ether0" , , "ether0")

    if strIP <> "" Then
       Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)

       objTextStream.WriteLine "/ip address"
       strPulo = 4
       strInicio = 1
       strQuantidade = 64
       For x = 1 to strQuantidade
          objTextStream.WriteLine "add address=" & strIP & strInicio & "/30" & " interface=" & strInterface
          strInicio = strInicio + strPulo
       Next
       objTextStream.Close
    End if
    ________________________________________________________________________________________________________
    Ok até ai tudo certo porque decidi fazer um script pra criar somente ip com /30
    mas seguido deste script vem outro veja...
    ________________________________________________________________________________________________________

    strFileName = "script.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")

    strIP = InputBox("ATENÇÃO!!!" & vbCrLf & "" & vbCrlf & "Qual é a classe de IP que você deseja usar" & vbCrLf & "" & vbCrLf & "ex: 192.168.0." , , "192.168.0.")
    strLimit = InputBox("ATENÇÃO!!!" & vbCrLf & "" & vbCrlf & "Qual é a velocidade que você deseja usar nos queues" & vbCrLf & "" & vbCrLf & "ex: 128" , , "128")

    if strIP <> "" Then
       Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)

       objTextStream.WriteLine "/queue simple"
       strPulo = 4
       strInicio = 2
       strQuantidade = 64
       For x = 1 to strQuantidade
          objTextStream.WriteLine "add name=" & "NewQueue-" & strIP & strInicio & " target-address=" & strIP & strInicio & "/32" & " max-limit=" & strLimit & "000/" & strLimit & "000"
          strInicio = strInicio + strPulo
       Next
       objTextStream.Close
    End if
    __________________________________________________________________________________________________________

    Observe que  nesse script o ip inicial é o 2 mas a quantidade é a mesma o ip tbm é o mesmo...

    eu queria que como ele ja esta fazendo ele fizesse mas com adcionais...
    eu executaria e ele ia me pedir a faixa de ip como está fazendo e a interface tbm como ja está fazendo.
    ele criaria o script e quando terminace me perguntace se eu queria continuar o script adcionando os queues.
    se eu responder não ele fexa ele termina porai, e se eu responder sim ele me pergunte qual a velocidade dos queues e termine...


    NETWAR TEAM
    terça-feira, 19 de maio de 2009 23:59
  • A ideia é chegar a um script que faça 1 script ou dois dependendo da resposta...

    /ip address
    add address=192.168.0.1/30 interface=ether0
    add address=192.168.0.5/30 interface=ether0
    add address=192.168.0.9/30 interface=ether0
    add address=192.168.0.13/30 interface=ether0
    add address=192.168.0.17/30 interface=ether0
    add address=192.168.0.21/30 interface=ether0
    add address=192.168.0.25/30 interface=ether0
    add address=192.168.0.29/30 interface=ether0
    add address=192.168.0.33/30 interface=ether0
    add address=192.168.0.37/30 interface=ether0
    add address=192.168.0.41/30 interface=ether0
    add address=192.168.0.45/30 interface=ether0
    add address=192.168.0.49/30 interface=ether0
    add address=192.168.0.53/30 interface=ether0
    add address=192.168.0.57/30 interface=ether0
    add address=192.168.0.61/30 interface=ether0
    add address=192.168.0.65/30 interface=ether0
    add address=192.168.0.69/30 interface=ether0
    add address=192.168.0.73/30 interface=ether0
    add address=192.168.0.77/30 interface=ether0
    add address=192.168.0.81/30 interface=ether0
    add address=192.168.0.85/30 interface=ether0
    add address=192.168.0.89/30 interface=ether0
    add address=192.168.0.93/30 interface=ether0
    add address=192.168.0.97/30 interface=ether0
    add address=192.168.0.101/30 interface=ether0
    add address=192.168.0.105/30 interface=ether0
    add address=192.168.0.109/30 interface=ether0
    add address=192.168.0.113/30 interface=ether0
    add address=192.168.0.117/30 interface=ether0
    add address=192.168.0.121/30 interface=ether0
    add address=192.168.0.125/30 interface=ether0
    add address=192.168.0.129/30 interface=ether0
    add address=192.168.0.133/30 interface=ether0
    add address=192.168.0.137/30 interface=ether0
    add address=192.168.0.141/30 interface=ether0
    add address=192.168.0.145/30 interface=ether0
    add address=192.168.0.149/30 interface=ether0
    add address=192.168.0.153/30 interface=ether0
    add address=192.168.0.157/30 interface=ether0
    add address=192.168.0.161/30 interface=ether0
    add address=192.168.0.165/30 interface=ether0
    add address=192.168.0.169/30 interface=ether0
    add address=192.168.0.173/30 interface=ether0
    add address=192.168.0.177/30 interface=ether0
    add address=192.168.0.181/30 interface=ether0
    add address=192.168.0.185/30 interface=ether0
    add address=192.168.0.189/30 interface=ether0
    add address=192.168.0.193/30 interface=ether0
    add address=192.168.0.197/30 interface=ether0
    add address=192.168.0.201/30 interface=ether0
    add address=192.168.0.205/30 interface=ether0
    add address=192.168.0.209/30 interface=ether0
    add address=192.168.0.213/30 interface=ether0
    add address=192.168.0.217/30 interface=ether0
    add address=192.168.0.221/30 interface=ether0
    add address=192.168.0.225/30 interface=ether0
    add address=192.168.0.229/30 interface=ether0
    add address=192.168.0.233/30 interface=ether0
    add address=192.168.0.237/30 interface=ether0
    add address=192.168.0.241/30 interface=ether0
    add address=192.168.0.245/30 interface=ether0
    add address=192.168.0.249/30 interface=ether0
    add address=192.168.0.253/30 interface=ether0
    /queue simple                                                                                                                      .............................ele poderá parar aqui ou continuar
    add name=NewQueue-192.168.0.2 target-address=192.168.0.2/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.6 target-address=192.168.0.6/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.10 target-address=192.168.0.10/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.14 target-address=192.168.0.14/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.18 target-address=192.168.0.18/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.22 target-address=192.168.0.22/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.26 target-address=192.168.0.26/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.30 target-address=192.168.0.30/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.34 target-address=192.168.0.34/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.38 target-address=192.168.0.38/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.42 target-address=192.168.0.42/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.46 target-address=192.168.0.46/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.50 target-address=192.168.0.50/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.54 target-address=192.168.0.54/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.58 target-address=192.168.0.58/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.62 target-address=192.168.0.62/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.66 target-address=192.168.0.66/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.70 target-address=192.168.0.70/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.74 target-address=192.168.0.74/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.78 target-address=192.168.0.78/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.82 target-address=192.168.0.82/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.86 target-address=192.168.0.86/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.90 target-address=192.168.0.90/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.94 target-address=192.168.0.94/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.98 target-address=192.168.0.98/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.102 target-address=192.168.0.102/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.106 target-address=192.168.0.106/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.110 target-address=192.168.0.110/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.114 target-address=192.168.0.114/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.118 target-address=192.168.0.118/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.122 target-address=192.168.0.122/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.126 target-address=192.168.0.126/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.130 target-address=192.168.0.130/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.134 target-address=192.168.0.134/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.138 target-address=192.168.0.138/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.142 target-address=192.168.0.142/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.146 target-address=192.168.0.146/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.150 target-address=192.168.0.150/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.154 target-address=192.168.0.154/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.158 target-address=192.168.0.158/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.162 target-address=192.168.0.162/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.166 target-address=192.168.0.166/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.170 target-address=192.168.0.170/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.174 target-address=192.168.0.174/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.178 target-address=192.168.0.178/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.182 target-address=192.168.0.182/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.186 target-address=192.168.0.186/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.190 target-address=192.168.0.190/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.194 target-address=192.168.0.194/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.198 target-address=192.168.0.198/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.202 target-address=192.168.0.202/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.206 target-address=192.168.0.206/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.210 target-address=192.168.0.210/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.214 target-address=192.168.0.214/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.218 target-address=192.168.0.218/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.222 target-address=192.168.0.222/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.226 target-address=192.168.0.226/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.230 target-address=192.168.0.230/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.234 target-address=192.168.0.234/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.238 target-address=192.168.0.238/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.242 target-address=192.168.0.242/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.246 target-address=192.168.0.246/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.250 target-address=192.168.0.250/32 max-limit=128000/128000
    add name=NewQueue-192.168.0.254 target-address=192.168.0.254/32 max-limit=128000/128000

    obrigado pela atenção

    NETWAR TEAM
    quarta-feira, 20 de maio de 2009 00:02