Assign different outputs of commands in terminal to different variables

Hello team,

As a junior developer in this field, I need your help with a problem that I am facing as below:
I have to run two scripts in terminal and assign their outputs in different variables (which I will need to copy to excel file later).

Currently I have used a Get Visible text activity to extract the data from terminal, and then used an assign activity to split the string into array of string with new line. Later I have used a “For each” activity to iterate through the array, and put a condition “If item is numeric” should be copied.

So, I need to assign a variable which retrieves the value of the first output, and assign another different variable to retrieve the value of second output. The problem is that since the outputs should be in the same visible window, the variables should extract different outputs. I tried to assign the item in the proper line of array but, when I write the output in excel file the values are blank.

image
image

Your help is really appreciated! Thank you!

@xhulia.kurteshi

Can you the output you are getting?
So, that we can check

Thanks

Hello @Srini84

There is no error shown actually, just that the value that needs to be read and assigned to variables is blank at the output file (seems not read and thus not written at the excel cells)

image

I think there is a problem with the assign activity, most probably with the expression inserted on it. I inserted item(71) and item(75) because I expect to read and assign the value of items in 71st 75th row respectively, but I am not sure if the expression is ok in this case.

out_noCredit = item(71).To String
out_Volte = item(75).To String

Thank you!

Hi again @Srini84 ,

I am inserting also a part of the xaml file: If_itemIsNumeric.xaml (9.0 KB)

Unfortunately, I can not insert the terminal screen photo because of security reasons.

image

Try inserting a “Write Line” activity, enter the variable name for the VB expression without quotes. put one right after you assign the variable and on right before you send the variable to Excel. after running your program open the Output tab (circled in red) and scroll though the output list and locate the values the variable had at each point. Also examine the Scope of your variable, It could be to local to be passing it to the Excel Sequence.

Hope this is not stating something you would find obvious.

Regards,
@ron.butler

Hello @ron.butler ,

Thanks for your suggestion. Following it, I managed to insert a write line activity to get the output of both commands in output session, as you may see below (with condition if item is numeric, as mentioned at first post):
image

Now, this variable (named out_Numerical) with both outputs is a string variable, and I need the first row of it (70457 in this case) to be assigned to a another variable. The same way, the other value (27752) to be assigned to a different value.

So, I tried to assign as below:
out_first = out_Numerical.item(0) → first value expected 70457
out_second = out_Numerical.item(1) → second value expected 27752

But I am getting error, saying: “item is not a member of string”. Do you know how to solve it?

Thank you!

I am not very knowledgeable about converting between the different Data types sorry, also I am not sure if the error is saying it is looking for the input to be changed to string or from string to another data type.
I have found two ways that work sometimes .To String or .As String to change to string.
.To Numeric or .As Numeric to change to a number type. I am afraid I use them as trial by error, as I don’t understand when to use which or when they will or will not work.

Thanks anyway Ron. Does anybody know how to solve it please? :roll_eyes:

Thank you in advance!