Page 1 of 1 1
Topic Options
#123949 - 2004-07-27 07:41 AM compare a file in a dir to a string inside a text file.....
TTripn Offline
Fresh Scripter

Registered: 2004-07-22
Posts: 8
Hi all,

If there is already a script that does this then please provide the link. If not, please provide info on how I can achieve this...


thankyou...

Top
#123950 - 2004-07-27 10:16 AM Re: compare a file in a dir to a string inside a text file.....
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Is this file in a static location?

_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#123951 - 2004-07-27 01:37 PM Re: compare a file in a dir to a string inside a text file.....
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
If the string includes the file location, this is as simple as:
1. Open the file and read the line to $MyStr
2. If Exist($MyStr) ...

Am I missing something?

NMM

Top
#123952 - 2004-07-28 01:06 AM Re: compare a file in a dir to a string inside a text file.....
TTripn Offline
Fresh Scripter

Registered: 2004-07-22
Posts: 8
the file is in a static location...
Top
#123953 - 2004-07-28 10:35 AM Re: compare a file in a dir to a string inside a text file.....
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Then New Mexico Marks reply is what you need

For Example

Code:
  


Open (1,"C:\temp\the name of your text file.txt")
Do
$MyStr= ReadLine(1)
If exist($MyStr)
;do whatever
Endif

Until $MyStr=""


_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#123954 - 2004-07-28 10:39 PM Re: compare a file in a dir to a string inside a text file.....
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Or do you want to check the contents of a file agaist the text string?

I think this needs a bit of clarification.

If the others have got it right just ignore me, my wife does so you can too.

If however they haven't got it right can you post some more info and an example of what you are trying to achieve.

Thanks
acmp<><
_________________________
Every day is a school day

Top
#123955 - 2004-07-29 02:12 AM Re: compare a file in a dir to a string inside a text file.....
TTripn Offline
Fresh Scripter

Registered: 2004-07-22
Posts: 8
Hi all,

This is what i want to do:

I have two txt files. Each file contains the @wksta. I want to compare the contents of both files. If the @wksta exist in only file 'A' then output the @wksta into another txt file. If exist in both 'A' and 'B' then execute xxx....

is this enough info?

thanxxxx

Top
#123956 - 2004-07-29 02:33 AM Re: compare a file in a dir to a string inside a text file.....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The easiest would be to just shell out and type and pipe to find.
Code:
break on
$A = 'C:\FileA.txt'
$B = 'C:\FileB.txt'

$ShellCMD = '%comspec% /c type "' + $A + '"| find /i "' + @WkSta + '"'

Shell $ShellCMD

If @Error = 1
'Computer ' + @WkSta + ' not found in ' + $A ?
EndIf

$ShellCMD = '%comspec% /c type "' + $B + '"| find /i "' + @WkSta + '"'

Shell $ShellCMD

If @Error = 0
'Computer ' + @WkSta + ' found in ' + $B ?
EndIf

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123957 - 2004-07-29 04:11 AM Re: compare a file in a dir to a string inside a text file.....
TTripn Offline
Fresh Scripter

Registered: 2004-07-22
Posts: 8
Hi Les,

Unfortunately your code only works if it is executed during the logon process. I'm actually looking for a script that can run independent of the logon process.

thankxx for the help....

Top
#123958 - 2004-07-29 04:42 AM Re: compare a file in a dir to a string inside a text file.....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might want to read ABC's of KiXtart board etiquette and message to new forum users and provide all necessary information!

Oh, and the code provided to you will work, independent of whether it's run as part of the login script or not. Logon scripts have per se nothing to do with KiXtart scripts. However, kiXtart scripts can be utilized as part of a logon procedure.
_________________________
There are two types of vessels, submarines and targets.

Top
#123959 - 2004-07-29 04:46 AM Re: compare a file in a dir to a string inside a text file.....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well, it does not take rocket science to replace the @WkSta macro with any computer name. This is not the drive-through window serving up ready code on a silver platter.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123960 - 2004-07-29 05:00 AM Re: compare a file in a dir to a string inside a text file.....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
But I can have fries with that, right? ;-)
_________________________
There are two types of vessels, submarines and targets.

Top
#123961 - 2004-07-29 05:25 AM Re: compare a file in a dir to a string inside a text file.....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Super size that?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123962 - 2004-07-30 12:54 AM Re: compare a file in a dir to a string inside a text file.....
TTripn Offline
Fresh Scripter

Registered: 2004-07-22
Posts: 8
Hi all,

Thankyou for all your help....appreciate it.
I managed to spring together these few lines of code and it seems to work for me..

break on
$txt1 = @LDRIVE + "\xxx.txt"
$txt2 = @LDRIVE + "\yyy.txt"
Open (1,$txt1)
$rl = ReadLine(1)
while @error=0
shell '%comspec% /c find /i "$rl" $txt2'
if @error=1
open(2,"%temp%\zzz.log",5)
$ = writeline(2,"$rl"+@crlf)
endif
$rl = readline(1)
loop
close(2)
close(1)

Top
#123963 - 2004-07-30 01:38 AM Re: compare a file in a dir to a string inside a text file.....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I can't see that working right. You have Open(2) inside the loop! You need to Open() it before the loop.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 962 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.068 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org