Run Cmd w/Capture Output - Not working

Discuss RoboTask here
Post Reply
darthtatertots
Posts: 5
Joined: Tue Aug 11, 2015 9:51 pm

Run Cmd w/Capture Output - Not working

Post by darthtatertots »

Hi there, I'm new to the forums, but not new the robotask. I've been using it for some time now, and just recently I've started exploring some more automation revolving around the use of the action "Run command-line utility". I've got several processes that I need to run a command line program and capture the output that's return to do some validation on. The problem is no matter what I do I cannot get the output of the command to return into a variable. To reduce the simplicity of my end goal, and to test if I'm doing something wrong, I tried creating a task to run the windows ping command and capture the results into a variable then show the results. This test also failed. Is anyone else experiencing this issue? Am I doing something wrong? Here's a copy of the task to capture the ping output which is failing.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1"
Hide=INTEGER|0
ID=INTEGER|869195475
LocalVariables=STRING|"RESULTS="
LogOnAsUser=INTEGER|1
Name=STRING|"Ping_Capture"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_MISC_RUNCONSOLEAPP"
Enabled=INTEGER|-1
Name=STRING|"Run command-line utility: PING.EXE 4.2.2.2"
Params=FOLDER

[Actions\Action1\Params]
convertansi=STRING|"0"
ifnonzero=STRING|"0"
outputvar=STRING|"{RESULTS}"
params=STRING|"4.2.2.2"
program=STRING|"C:\Windows\System32\PING.EXE"
saveexitcode=STRING|"0"
saveoutput=STRING|"1"
workdir=STRING|"C:\Windows\System32"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Results: {RESULTS}"""
Params=FOLDER

[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"Results: {RESULTS}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Cmd w/Capture Output - Not working

Post by Oleg »

You should use varable name only in Run command-line utility action
See screenshot:
ping.png
ping.png (21.56 KiB) Viewed 16064 times
Also see corrected task below. Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1"
Hide=INTEGER|0
ID=INTEGER|869195475
LocalVariables=STRING|"RESULTS="
LogOnAsUser=INTEGER|1
Name=STRING|"Ping_Capture"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_MISC_RUNCONSOLEAPP"
Enabled=INTEGER|-1
Name=STRING|"Run command-line utility: PING.EXE 4.2.2.2"
Params=FOLDER

[Actions\Action1\Params]
convertansi=STRING|"0"
ifnonzero=STRING|"0"
outputvar=STRING|"RESULTS"
params=STRING|"4.2.2.2"
program=STRING|"C:\Windows\System32\PING.EXE"
saveexitcode=STRING|"0"
saveoutput=STRING|"1"
workdir=STRING|"C:\Windows\System32"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Results: {RESULTS}"""
Params=FOLDER

[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"Results: {RESULTS}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Read more about usage of variables here: http://www.robotask.com/forum/viewtopic.php?f=4&t=1621
Oleg Yershov
darthtatertots
Posts: 5
Joined: Tue Aug 11, 2015 9:51 pm

Re: Run Cmd w/Capture Output - Not working

Post by darthtatertots »

Ahh! Many thanks! Might I suggest that when you click the {v} button to select variables (to add them into that field) that is removes the brackets when you click ok? Or perhaps some sort of note in the documentation indicating not to include the brackets? I scoured through the documentation and never saw anything about that (I might have missed it still). Thanks!
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Cmd w/Capture Output - Not working

Post by Oleg »

In this case you have to input the name of your own variable.
Also you can compose the name with using another variable. For example: MyVar{num}
This can create enumerated variables: MyVar1, MyVar2, MyVar3, and so on
Oleg Yershov
Post Reply