akiwa

read string in file

3 posts in this topic

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

Share this post


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Danyfirex thanks before, but  i have 2 ip (one ip for virtual machine), how can i get only one IP ex: 192.168.0

Thankyou
 

Edited by akiwa

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