Find text string in TXT hosted on Server.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Find text string in TXT hosted on Server.

#1 Post by MauricioDeAbreu » 30 Jan 2022 07:19

Friends, I need to search for a text string (Laptop Serial. Example 1SWA12F45G68B2) in a TXT file (Serials.txt), but this TXT file is hosted on an IP address of a server.

This Batch would run under the following Operating Systems: Windows XP, Seven and 10

Is there a way to do it from a Batch?

Thanks in advance for any help you can give me.

Excuse my English, I use a translator.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Find text string in TXT hosted on Server.

#2 Post by Squashman » 30 Jan 2022 10:22

So you know the name of the server. You know the severs ip address. You know the name of the file you need to search. You know what the search string is. What is your problem?

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Find text string in TXT hosted on Server.

#3 Post by MauricioDeAbreu » 30 Jan 2022 11:06

The problem is that I don't know how to do it :-(

This is how I do it in the same directory.

@Echo Off
::test value
set serial=1S2887PS099XGA21

Find "%serial%" Seriales.txt >NUL
If %ERRORLEVEL% EQU 1 (
Echo serial does not exist : %serial%
) Else (
Echo Serial existe: %serial%
)
pause

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Find text string in TXT hosted on Server.

#4 Post by Squashman » 30 Jan 2022 11:42

So if you have files on another computer on your network how do you get to them?

(Teaching you to fish)

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Find text string in TXT hosted on Server.

#5 Post by MauricioDeAbreu » 30 Jan 2022 13:18

I was looking for information about it, and on this page https://docs.microsoft.com/es-es/dotnet ... th-formats I found the following:

Code: Select all

@"\\127.0.0.1\c$\temp\test-file.txt"
I guess it would be something like this:

Code: Select all

@Echo Off
::test value
set serial=1S2887PS099XGA21

Find "%serial%" @"\\127.0.0.1\c$\Seriales.txt” >NUL
If %ERRORLEVEL% EQU 1 (
Echo serial does not exist : %serial%
) Else (
Echo Serial existe: %serial%
)
pause
I don't know if the double \\, the @ or the c$ is used

Thanks for your time

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Find text string in TXT hosted on Server.

#6 Post by ShadowThief » 30 Jan 2022 13:31

You can't interact with remote files.

Download the file and interact with the local copy.

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Find text string in TXT hosted on Server.

#7 Post by MauricioDeAbreu » 31 Jan 2022 09:22

Thanks for answering.

And how do you copy a file located on a server? :oops:

Thanks in advance for the help.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Find text string in TXT hosted on Server.

#8 Post by ShadowThief » 31 Jan 2022 09:55

curl, generally, since that's built into Windows 10 and 11.

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Find text string in TXT hosted on Server.

#9 Post by MauricioDeAbreu » 31 Jan 2022 12:48

And Curl can be used on Windows Xp and Seven ?

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Find text string in TXT hosted on Server.

#10 Post by ShadowThief » 31 Jan 2022 14:40

You'd have to install it separately, but Windows XP and 7 are wildly out of date and shouldn't be used.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Find text string in TXT hosted on Server.

#11 Post by atfon » 01 Feb 2022 10:22

For older operating systems, you could potentially use BitsTransfer with powershell as in this StackOverflow Answer:

https://stackoverflow.com/questions/302 ... lternative

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Find text string in TXT hosted on Server.

#12 Post by MauricioDeAbreu » 01 Feb 2022 16:59

Thank you for your answers.

Due to the activities we do, it is impossible to leave Windows XP (64bit) and Windows Seven.

At work we use three operating systems, Windows XP (64bit), Windows Seven and Windows 10.

So any code you make must be compatible with all three operating systems.

Regarding my question, and from what you guys say, it's impossible to do the following with Batch alone:
1- Look for the serial of the laptop in a txt file that is in another computer (server).
2- Copy a TXT file from one computer (server) to another computer (Laptop).

If these statements are correct, I have to find an alternative to look up the equipment serial in a list. It is essential that the serial is validated in the file or list.

So I'm wondering:
Will it be possible to search for the serial (text string) in a list that is on a web page on another computer (server)?
That is, query the serial at 192.168.100.2/serials.html or something like that.

Any ideas.

I am going to read about BITSAdmin.exe

Post Reply