Jump to content

Feed A Script A Text File


Recommended Posts

Sorry if this is posted somewhere but I must be looking with the wrong key words. Does anyone know how to feed a list of ip addresses into a scrip and then stop at the end

ex

ping iplist.txt

where the ip list is

10.0.0.1

10.0.0.2

192.168.0.1

etc

I know this can not be to hard....just to hard for me

Link to comment
Share on other sites

  • Developers

Sorry if this is posted somewhere but I must be looking with the wrong key words. Does anyone know how to feed a list of ip addresses into a scrip and then stop at the end

ex

ping iplist.txt

where the ip list is

10.0.0.1

10.0.0.2

192.168.0.1

etc

I know this can not be to hard....just to hard for me

look at FileOpen() and Filereadline() examples and replace the msgbox of the ping function

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Be careful though, it looks like you're trying to ping the global range of IP addresses, and some places don't like to be pinged. A friend got in trouble with the FBI for attempting to peek at a certain range of IPs, can't remember the range though. Be warned!

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
Share on other sites

ok let me clerify. Ping was just an example, also note all addresses are private addrersses.

the problem with the read line option is I still ahve to create a script line for each line in the text file I am looking for a way to add a whole file reguardless of the number of entries

Link to comment
Share on other sites

ok let me clerify. Ping was just an example, also note all addresses are private addrersses.

the problem with the read line option is I still ahve to create a script line for each line in the text file I am looking for a way to add a whole file reguardless of the number of entries

read up on StringSplit() _FileReadToArray(), and FileRadLine
Link to comment
Share on other sites

Hi,

hmh, something like that?

#include <file.au3>
#include<Array.au3>
$file = FileOpen("c:\Downloads\AutoIt-Skripte\Entwicklung\iplist.txt", 0)
Dim $aRecords
If Not _FileReadToArray("c:\Downloads\AutoIt-Skripte\Entwicklung\iplist.txt" ,$aRecords) Then
   MsgBox(4096,"Error", "Ip-list error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
Next
_ArrayDisplay($aRecords, "IPList")
FileClose($file)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Be careful though, it looks like you're trying to ping the global range of IP addresses, and some places don't like to be pinged. A friend got in trouble with the FBI for attempting to peek at a certain range of IPs, can't remember the range though. Be warned!

Those are all reserved IP addresses... they are reserved for Local Area Networks...

No problem if you ping those, just watch out for the Class D and Class E ranges. (Reserved for Multicast and Experimental Purposes respectively)

Link to comment
Share on other sites

hey thanks I am almost there, now how do I say ping each of those ip addresses?

_______________________________________________

#include <file.au3>

#include<Array.au3>

$file = FileOpen("\iplist.txt", 0)

Dim $aRecords

If Not _FileReadToArray("iplist.txt" ,$aRecords) Then

MsgBox(4096,"Error", "Ip-list error:" & @error)

Exit

EndIf

For $x = 1 to $aRecords[0]

Next

_ArrayDisplay($aRecords, "IPList")

FileClose($file)

Link to comment
Share on other sites

Link to comment
Share on other sites

ping was just an example auctually I am backing up switches

I need to run sftp login@iplist......... for each switch

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

; Your ftp command here

Wend

FileClose($file)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...