Sign in to follow this  
Followers 0
AntiVirusGuy

Feed A Script A Text File

11 posts in this topic

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

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0