Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Randomize reading a file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,31558
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Randomize reading a file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Randomize reading a file - 2/26/2006 8:42:48 PM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
Hello guys just a quick one


Right basically i have a script for connecting to machines via remote control and logging them in using send keys. The script reads the machine names from a text file. I need the script to read the text file but not in the order they are arranged (if that maes sense) but the same line cannot be repeated.

any ideas or help would be much appreciated

thanks in advance
 
 
Post #: 1
 
 RE: Randomize reading a file - 2/26/2006 10:13:42 PM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
You can read them into an array or dictionary object.  What order do you need to access the items (machine names)?

Cybex

_____________________________

Common sense is not so common.

(in reply to silentmelons)
 
 
Post #: 2
 
 RE: Randomize reading a file - 2/26/2006 10:56:26 PM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
ok here is an example of the txt file it will be reading
RS0001E06
RS0001E07
RS0001E08
RS0004E06
RS0004E07
RS0004E08
RS0004E09
RS0004E10
RS0004E11
RS0004E35
RS0007E06
RS0007E07
RS0007E08
RS0007E09
RS0007E10
RS0007E11
RS0007E12
RS0007E13
RS0007E14
RS0007E15
RS0007E16
RS0007E17
RS0007E18


There would be thousands of machine names in this txt file i need the script to run against all machine names. The rs**** represents a store number i need to run the script against one store then a diff one for example. It would run against rs0001e06 and then rs0007e09 then rs0004e35 and so on. Its not a great problem if it does run on multiple machines from the same store but this seriously effects bandwith so one at a time would be best. Hope that makes sense

(in reply to silentmelons)
 
 
Post #: 3
 
 RE: Randomize reading a file - 2/26/2006 11:26:33 PM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Is this how the numbering is broken down, RS000[store]E[machine][machine]?


Cybex

_____________________________

Common sense is not so common.

(in reply to silentmelons)
 
 
Post #: 4
 
 RE: Randomize reading a file - 2/26/2006 11:28:01 PM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Try this.


      

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to silentmelons)
 
 
Post #: 5
 
 RE: Randomize reading a file - 2/26/2006 11:35:39 PM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Hmm, I just noticed I get an "Out Of Memory" error with that code and I don't know why.....

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to ginolard)
 
 
Post #: 6
 
 RE: Randomize reading a file - 2/26/2006 11:45:16 PM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
yeah i get the same out of mem error when running that code.

Can you show me how to incorporate that into my current script. I dont really know a great deal about sub routines and arrays


      

< Message edited by silentmelons -- 2/26/2006 11:54:03 PM >

(in reply to silentmelons)
 
 
Post #: 7
 
 RE: Randomize reading a file - 2/27/2006 12:13:16 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Not best practice but "On Error Resume Next" does seem to let it finish with all 23 names being randomly displayed.


      


Cybex

_____________________________

Common sense is not so common.

(in reply to silentmelons)
 
 
Post #: 8
 
 RE: Randomize reading a file - 2/27/2006 12:14:29 AM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Yeah I noticed that too but it's bugging me as to why it's happening. 

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to Cybex)
 
 
Post #: 9
 
 RE: Randomize reading a file - 2/27/2006 12:16:55 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Good start, but it doesn't address or attempt to prevent mutiple systems from the same location from being ran concurrently. 


Cybex

_____________________________

Common sense is not so common.

(in reply to ginolard)
 
 
Post #: 10
 
 RE: Randomize reading a file - 2/27/2006 12:21:04 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
It seems even though you are checking to ensure the return value is not outside of the value range it does seem to exceed it.  Is it always on the last record for you as well?


Cybex

_____________________________

Common sense is not so common.

(in reply to ginolard)
 
 
Post #: 11
 
 RE: Randomize reading a file - 2/27/2006 12:24:47 AM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
yes always on the last record

(in reply to silentmelons)
 
 
Post #: 12
 
 RE: Randomize reading a file - 2/27/2006 12:26:49 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Ginolard,

I think the issue is with "LinetoRead=(Int((UBound(Arrayfile)-1)*Rnd))", run the script below and review to output on the last element as it runs through.


      


Cybex

_____________________________

Common sense is not so common.

(in reply to Cybex)
 
 
Post #: 13
 
 RE: Randomize reading a file - 2/27/2006 12:39:09 AM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
sorry what. I dont see how thats gonna work sorry like  said i am new to this and very inexperienced. I see what your doing there but how do i link that to my current script

(in reply to Cybex)
 
 
Post #: 14
 
 RE: Randomize reading a file - 2/27/2006 12:43:18 AM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Well, where this bit of script does "WScript.echo Arrayfile(LineToRead)" you would call your code to go and connect to the machine and do whatever needs doing.  It would best to put your code in a Sub

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to silentmelons)
 
 
Post #: 15
 
 RE: Randomize reading a file - 2/27/2006 12:51:22 AM   
  silentmelons

 

Posts: 23
Score: 0
Joined: 11/25/2004
From: United Kingdom
Status: offline
Thanks guys i have it slightly working let me have a play and i will let you know how i get on

(in reply to ginolard)
 
 
Post #: 16
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Randomize reading a file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts