Jump to content

PuTTY output to array


jyym
 Share

Recommended Posts


Hi guys, need some quick hints or help here :)

So I need to create two scripts that inteded to be used for end-user/non-technical users.  First script, to connect to my Ubuntu from Dos, autologin and run specific software that will end up on a CLI prompt. For this I didn't need AutoIt to do it.

The second script is to be executed few minutes after the first script run (depends on request). This second script will execute 2 commands on the CLI that will take and loop on array values. I can do this with no problem.

However, the array values will be taken from an output from the CLI program.

So, I need to run a command on the CLI program on Ubuntu and it will give me something like

No   Reg               Time  Active
1      12121212     912   14
2      23231312     123   12
3      112121211    121   12

I need to take only the "Reg" values and place them in one array variable.

I don't need you to solve this everything of couse (but if you do, I don't mind) but some few hints and example would be much appreciated.
I have googled around but the example were for some complicated script and they are used if you are running them in one whole script (mine need to  be separated as the second script is not executed right away).
Thanks a bunch!

cheers,
Jess

 

 

Link to comment
Share on other sites

#include <Array.au3>

Global $Data = "No   Reg               Time  Active" & @CR & _
        "1      12121212     912   14" & @CR & _
        "2      23231312     123   12" & @CR & _
        "3      112121211    121   12"

Global $Split1 = StringSplit($Data, @CR)
_ArrayDisplay($Split1)

Global $Split2

For $i = 2 To $Split1[0]
    $Split1[$i] = StringStripWS($Split1[$i], 7)
Next
_ArrayDisplay($Split1)

For $i = 2 To $Split1[0]
    $Split2 = StringSplit($Split1[$i], " ")
    $Split1[$i] = $Split2[2]
Next
_ArrayDisplay($Split1)

_ArrayDelete($Split1, "0;1")
_ArrayDisplay($Split1)

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...