0

Trying to use rpyc server via progress script, and have the script do different tasks based on different values I'm trying to get from the client.

I'm using a rpyc server to automate some tasks on demand from users, and trying to implement the client in a progress script in this way:

1.progress script launches.

2.progress script calls the rpyc client via cmd, to run a function that checks if the server is live, and returns some sort of var to indicate wether the server is live or not (doesn't really matter to me what kind of indication is used, I guess different chars like 0-live 1-not live would be preferable).

3.based on the value returned in the last step, either notifies the user that the server is down and quits, or proceeds to the rest of the code.

The part I'm struggling with is stage 2, how to call the client in a way that stores a value it should return, and how to actually return the value properly to the script.

I thought about using -param command, but couldn't figure how to use it in my scenario, where the value I'm trying to return is to a script that already midrun, and not just call another progress script with the value.

The code of the client that I use for checking if the server is up is:

def client_check():
  c=rpyc.connect(host,18812)

if __name__=="__main__":
  try:
    client_check()
  except:
    #some_method_of_transferring_the_indication#

For the progress script, as mentioned I didn't really managed to figure out the right way to call the client and store a value in the way I'm trying to..

I guess I can make the server create a file that will use as an indicator for his status, and check for the file at the start of the script, but I don't know if that's the right way to do so, and prefare to avoid using this if possible.

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
Roman
  • 37
  • 1
  • 8

1 Answers1

2

I am guessing that you are saying that you are shelling out from the Progress script to run your rpyc script as an external process?

In that case something along these lines will read the first line of output from that rpyc script:

define variable result as character no-undo format "x(30)".

input through value( "myrpycScript arg1 arg2" ).   /* this runs your rpyc script */
import unformatted result.               /* this reads the result */
input close.

display result.
Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
  • Couldn't edit my comment by now, but I have a follow up question, if I need to use that method to run a client, with arguments being passed from my progress script, how should I do it correctly? – Roman Jun 25 '19 at 14:25
  • The string provided to INPUT THROUGH is whatever you would do at the command line. So just add the arguments there. It does not have to be a literal string. It can be an expression and you can build it up from variables if you would like. – Tom Bascom Jun 25 '19 at 19:18