Page 1 of 1 1
Topic Options
#191628 - 2009-01-05 09:40 PM Xporting words starting with specific letters from 1 kix script to txt file
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
Hi Guys,

Im trying to export workstation names from a Kix script into a text file

so for instance. I have a kix scripts that has a
If @wksta = "ws****"
? do this
else
?do this

so i want to have a script that looks through the existing script and finds any words with WS at the beggining of it and exports the whole name of the computer to a text document then moves onto the next. this is so they can be used later to have a script that moves them all into a group in AD. There are about 400 of them, hense wanting to do it scripted.

Im hoping someone out there can give me a pointer in the right direction.

Much appreciated :-)

Top
#191629 - 2009-01-05 09:50 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Reg_D]
eriqjaffe Offline
Hey THIS is FUN

Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
You can use the Left() function to determine if the pattern matches:

 Code:
if left(@WKSTA,2) = "ws"
     do something
else
     do something else
endif

Top
#191632 - 2009-01-05 10:00 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: eriqjaffe]
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
cheers for that, tis appreciated

just wondering how you incorporate that into reading a script first???

has got me...... wanna basically run like a find that you can do in notepad and when it finds a result export it to a text doc.

might not even be possible??

Cheers

Top
#191633 - 2009-01-05 10:24 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Reg_D]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
come on, everything is possible.
_________________________
!

download KiXnet

Top
#191634 - 2009-01-05 10:28 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Lonkero]
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
Ha ha, the optimist :-)
Top
#191635 - 2009-01-05 10:28 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
your second post was kinda confusing, but your first post gives the rules...

so, you can use the good old open(), writeline(), close() method.
it can be too taxing on the coding so there are couple shorthands, like redirectoutput()

then you can always use the lazy way:
shell "%comspec /c echo "+@wksta+" >> path_to_that_file_dude.txt"
_________________________
!

download KiXnet

Top
#191638 - 2009-01-05 10:39 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Lonkero]
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
sorry, I perhaps have been sloppy in explaining. I have a script with:

if @wksta = "ws****

Top
#191640 - 2009-01-05 10:45 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Reg_D]
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
sorry computer went funny.

I think perhaps have been sloppy in explaining. I have a script currently with:

if @wksta = "ws****1"
do this
else
do this
endif

if @wksta = "ws****2
do this
else
do this
endif

which serves a purpose for another app. this then repeats about 4 hundred times and the ws number is unique every time. I want a script to read all these WS values and export them on their own to a text document seperated by a comma (preferably).

Hope that is clearer

Top
#191642 - 2009-01-05 11:18 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Reg_D]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Not a silver platter, but to get you on the right track....
 Code:
Open(1,"TheScript.KIX",2)
Open(2,"TheOutPut.CSV",5)
$Line = Readline(1)
While @Error = 0
  $Array = Split($Line," ")
  $Location = Left(ASCAN($Array,"ws"),3)
  If $Location > -1
    Writeline(2,$Array[$location] + ",")
  EndIf
  $Line = Readline(1)
Loop
Close(1)
Close(2)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191643 - 2009-01-05 11:20 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Reg_D]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
for $n=1 to 400 ; or whatever is your real number in the end...
if @wksta = "ws****"+$n
SHELL "comspec /c echo me lazy, "+@wksta+" >> c:\my\folder\where_is-dast."+$n+".txt"
endif
_________________________
!

download KiXnet

Top
#191644 - 2009-01-05 11:20 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
gargoyle, not a silver platter?
_________________________
!

download KiXnet

Top
#191646 - 2009-01-05 11:22 PM Re: Xporting words starting with specific letters from 1 kix script to txt file [Re: Lonkero]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Just silver plated.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191648 - 2009-01-06 12:30 AM Re: Xporting words starting with specific letters from 1 kix script to txt [Re: Gargoyle]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Well you can't be too lazy Lonk if you're doing Golfing in the first place.
Top
#191668 - 2009-01-06 10:44 AM Re: Xporting words starting with specific letters from 1 kix script to txt [Re: NTDOC]
Reg_D Offline
Fresh Scripter

Registered: 2008-10-29
Posts: 12
Cheers guys, I'll look into that today.

not really done anything like gargoyles solution before. be a good learning curve :-)

Cheers again

Top
#191678 - 2009-01-06 09:11 PM Re: Xporting words starting with specific letters from 1 kix script to txt [Re: Reg_D]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Give it a try before Jooel get's bored and Golf's it down to something unreadable ;\)
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 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.176 seconds in which 0.115 seconds were spent on a total of 13 queries. Zlib compression enabled.

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