MsNet send response before end of script

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MarcinW
Junior Coder
Posts: 23
Joined: Thu Jul 23, 2020 11:24 pm

MsNet send response before end of script

Post by MarcinW » Wed Oct 14, 2020 10:02 pm

Hi, I've noticed that when triggering a script through MsNet API call, response is not sent back until the whole script is executed. Initially I thought that response was sent at the point of Let>MACRO_RESULT variable. However it seems like this is not the case. I need response to be sent immediately, whereas the whole script can take few mins to finish.

Can this be done?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1350
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MsNet send response before end of script

Post by Dorian (MJT support) » Thu Oct 15, 2020 10:05 am

Macro_Result is returned when the script finishes running.

But this got me thinking.

Why not have two scripts? The first one simply returns "Please Wait..", and then redirects to a page which runs the actual script. Here's a video of it working.

//Script1 Saved as "msn1.scp" and called via http://192.168.1.205:2222/msn1 :

Code: Select all

LabelToVar>HTML,TheHTML
let>Macro_result=TheHTML

/*
HTML:
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="refresh" content="3; url='http://192.168.1.205:2222/msn2'" />
  </head>
  <body>
    <p>Please wait...processing...  </p>
  </body>
</html>
*/


//Script2 Saved as "msn2.scp" and called via the first script at http://192.168.1.205:2222/msn1 :

Code: Select all

let>Macro_result=Second Script Completed
Yes, we have a Custom Scripting Service. Message me or go here

MarcinW
Junior Coder
Posts: 23
Joined: Thu Jul 23, 2020 11:24 pm

Re: MsNet send response before end of script

Post by MarcinW » Thu Oct 15, 2020 4:17 pm

I found a different solution to the problem. API triggers script built for running the compiled bot. It returns response straight away without blocking calling program and compiled bot is free to take its time to complete the process:

Code: Select all

RunProgram>{%str_path% + %str_file% + " /_test=ABC /_test2=123"}

Let>MACRO_RESULT={"Quick Response"}
Thanks for your suggestion though, I'll keep in mind if I'll need to return response upon initialisation and end of the process. :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts