Sign in to follow this  
Followers 0
Flash1212

Read file into array and relay to script

5 posts in this topic

So, being the newbie here at my job it seems that they want to give me the task that to me seems impossible :) . They want me to right two scripts that will work together with a .csv file. The 1st script is suppose to activate another script in a interactive session on a remote computer. The even more tricky part to this is that there will be 25 computers with the same script that need to be activated :P . The script that is activated (2nd Script) will look for a .csv file (this file has the 25 machines listed before in it) on a network share and look for it's name. Once it finds it's name it then needs to look at the value next to it which will contain a time ( ie: 14:35) and place that time into a $variable which resides on the 1st script. It will then check that time against the current time so that it knows when it needs to run the rest of the script. The $variable and time part aren't so difficult it's the reading a file into what I believe needs to be a 2D array (Computername, 14:35) that I can't seem to grasp. I can't even get the _filereadtoarray to work right for me. I've been trying different things for 2 days :) as well as crawling the forum. I really need some help please!! :P


**The only limit is what you believe they tell you it is**

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe...

#include <file.au3>

Dim $Location = "C:\Folder\FileName.cvs" ; where is the file to read???

Dim $aRecords, $Info


If Not _FileReadToArray($Location,$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf

For $x = 1 to $aRecords[0]
    If StringInStr($aRecords[$x], @ComputerName) Then 
        $Split = StringSplit($aRecords[$x], ",")
        $Info = $Split[2]
        ExitLoop
    EndIf
Next

MsgBox(0x0, "time info", $Info)

8)

UPDATED....

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Thank YOU!!! It worked great. Now you wouldn't by any chance happen to know how the remote interactive start would work would you? :)


**The only limit is what you believe they tell you it is**

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Welcome!!

Maybe...

add to the other script Run( "ProgramName.exe " & $info)

Below is the begining of "ProgramName.exe" that accepts the argument of $info to run

If $CMDLine[0] > 0 Then
    If Not StringInStr($CMDLine[1], ":") And Not StringLen($CMDLine[1]) = 5 Then Exit
    GetSource ($CMDLine[0])
EndIf
Exit

Func GetSource ($info)
    ; do what you want
    MsgBox(0x0, "test", $info)
    Exit
EndFunc   ;==>GetSource

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Thank you for all your help Valuater. I will incorperate this into this script to get it to work. Now I need to start reading more so I can understand how you got this to work. :)


**The only limit is what you believe they tell you it is**

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
Sign in to follow this  
Followers 0