Looking for a simple example for networkcommand.exe

Discuss RoboTask here
Post Reply
pkwong
Posts: 2
Joined: Wed Apr 06, 2022 3:33 pm

Looking for a simple example for networkcommand.exe

Post by pkwong »

Hi. Here's to hoping someone can provide a simple command example:

I have a need to use the networkcommand.exe CLI (via dos) to set 2 local variables, then run a task.

Here are some known basics (for the purpose of the example):

Robotask Name: example-login
Variable1={USERNAME}
Variable2={PASSWORD}
ip of host listener: 192.168.1.10
port: 5500

Listener set up: (there are 3)

Listener 1:

Network->Listener
(Starts with) Wait for String = "APPUSER=" -----> "Save Received string as Local User Variable --> {USERNAME}"

Listener 2:

Network->Listener
(Starts with) Wait for String = "PASSWORD=" -----> "Save Received string as Local User Variable --> {PASSWORD}"

Listener 3:

Network->Listener
(Exact String): example-login ---> Everything else blank. This will be to start the task if it sees "example-login" as the string.

So.. on the machine I want to use networkcommand.exe on, I'm issuing the following command (from the dos prompt):

networkcommand.exe srv=192.168.1.10 cmd="APPUSER=myuser" port=5500

I get the following response:
Receive data: Timeout is over or unexpected connection closing

What I'm trying to achieve is:

1. Set Username
2. Set Password
3. Run the task

Where am I going wrong? Any help would be very much appreciated. The console of the "server" machine where the task will be run sees the connection coming in.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Looking for a simple example for networkcommand.exe

Post by Oleg »

1. The default port for Listener trigger is 5254. You can set your parameters in Network Plugin settings.
Just click on the button "Plugin settings" of trigger editor.
2-nd way:
  • open dialog Options | settings
  • Go to Plugins tab
  • find and select Network plugin
  • press Configure button
Default port 5500 is for client-server functions and has different protocol. So you got an error.
Listener launches the task and it can pass received value to the task as local variable

2. Look at my example below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
Do not forget to enable the task after importing.

Listener trigger starts the task and it reacts to the string "runtask" in the beginning of the command.
Listener port is 5254 without password

Next you can use NetWorkCommand.exe with this command line
NetWorkCommand.exe srv=localhost cmd="runtask,MyUserName,MyPassword" port=5254

The command as comma-separated string:
1-st element is the command
2-nd element the user name
3-nd element the password

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task77"
Hide=INTEGER|0
ID=INTEGER|1328771684
LogOnAsUser=INTEGER|1
Name=STRING|"Example for Listener"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""usr"" with value ""{FullCommand(1)}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"usr"
varvalue=STRING|"{FullCommand(1)}"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""psw"" with value ""{FullCommand(2)}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varname=STRING|"psw"
varvalue=STRING|"{FullCommand(2)}"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Run something """
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Run something "
msg1=STRING|"received command {FullCommand}"
msg3=STRING|"username = {usr}"
msg4=STRING|"password = {psw}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_NET_LISTENER"
Name=STRING|"Listener"
Params=FOLDER
UniqueID=INTEGER|961308698

[Events\Event1\Params]
assign=STRING|"0"
case=STRING|"0"
option=STRING|"1"
parameter=STRING|"FullCommand"
string=STRING|"runtask"
useparameter=STRING|"1"
Oleg Yershov
pkwong
Posts: 2
Joined: Wed Apr 06, 2022 3:33 pm

Re: Looking for a simple example for networkcommand.exe

Post by pkwong »

Thank You so much! It was a very clear and concise example!

Cheers.
Post Reply