Jump to content

read string in file


akiwa
 Share

Recommended Posts

hello everyone, i need help
how to take the word of a file, for example :

IP.txt
-------------------------------------
address ..... 192.168.0.1
address ..... 192.168.1.1
address ......192.168.2.1
------------------------------------------

I want to take some of the words, ex: 192.168.0, and i want comparison with some string

---------------------------------------------------------------------------------------------------------------------------

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Date.au3>

$sUserName = "admin"
$sPassword = "admin"
$rundst = @TempDir & "\ccleaner.exe"

Local Const $filePath=@TempDir & "\ip.txt"
$IP = $filePath, $Search " 192.168.0"        <====   this part

$CurrentDate = _NowDate()
$CurrentDay = _DateDayOfWeek(@WDAY)

if (($CurrentDay == "Friday") and ($IP = "192.168.0" ) then

Local $iPID = RunAsWait($sUserName, @computername, $sPassword, $RUN_LOGON_NOPROFILE, $rundst, @SystemDir, @SW_MAXIMIZE)

else
MsgBox($MB_SYSTEMMODAL, "Info", "thanks")

---------------------------------------------------------------------------------------------------------------------------------------------------------

many many thanks before

Link to comment
Share on other sites

This way you can get all IPs.

 

#include <Array.au3>
Local $sFileData = FileRead("1.txt")
Local $aIPs = StringRegExp($sFileData, '\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b', 3)
_ArrayDisplay($aIPs)

Saludos

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...