Msnet, RP_RESULT

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
BobDDstryr
Junior Coder
Posts: 38
Joined: Fri Oct 22, 2010 2:47 am

Msnet, RP_RESULT

Post by BobDDstryr » Fri Feb 25, 2011 6:27 am

So I have a number of scripts on one machine, all called with the macro command from a main script:
macro>D:\script1.scp

In script1.scp, I set MACRO_RESULT=TRUE or FALSE depending on how it went, so then in main I can look at %MACRO_RESULT% and react accordingly, and that all works fine.

So - I want to use msnet to run main from a second machine:
run>msnet client 6666 D:\main.scp

And then I want the second machine to know whether or not main.scp passed - so I was trying to have:
let_rp_wait=1
run>msnet client 6666 D:\main.scp
if>%RP_RESULT%=TRUE
...

However, %RP_RESULT% seems to always be set to 0, no matter what MACRO_RESULT is set to at the end of main.scp. Is there a way to have main.scp return a value to the second machine that kicked it off via msnet?

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 25, 2011 7:22 am

msNet uses HTTP. So you should use HTTPRequest to run the remote macro and get the result back:

HTTPRequest>http:\\client:6666\main.scp,,GET,,result

result will now contain the response which main.scp sets in MACRO_RESULT

Or:

Code: Select all

VBSTART
Function HTTPGet(URL)
  Set IE = CreateObject("InternetExplorer.Application")
  IE.visible = 0
  IE.navigate URL
  do while IE.Busy
  loop
  HTTPGet = IE.document.documentelement.outerhtml
  IE.quit
  Set IE = Nothing
End Function
VBEND
VBEval>HTTPGet("hhttp:\\client:6666\main.scp"),HTMLResult
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BobDDstryr
Junior Coder
Posts: 38
Joined: Fri Oct 22, 2010 2:47 am

Post by BobDDstryr » Fri Feb 25, 2011 8:14 pm

Hey Marcus - thanks, but now I have another question.

My scripts need to pass variables as well - doing that with msnet is easy enough:
run>msnet client 6666 D:\macro\main.scp /variable1=X /variable2=Y

However I can't figure out how to do that with HTTPRequest
let>postdata=variable1=X&variable2=Y
HTTPRequest>http:\\client:6666\main.scp,,GET,%postdata%,result
This ignores the post data, since its not a post command.

HTTPRequest>http:\\client:6666\main.scp,,POST,%postdata%,result
This doesn't actually run main.scp - when I print out %result% afterwards its set to: 200 HTTP/1/1 200 OK

So is there a way to format an HTTPRequest command to do a get, but passing variables to the function?

I'm not really familiar with either VB or http protocols, is there an easy way to modify your VBscript to pass variables?

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 25, 2011 8:17 pm

It's a GET not a POST so you would do:

HTTPRequest>http:\\client:6666\main.scp?variable1=X&variable2=Y,,GET,%postdata%,result

It's just HTTP so the same format as any URL query string.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BobDDstryr
Junior Coder
Posts: 38
Joined: Fri Oct 22, 2010 2:47 am

Post by BobDDstryr » Fri Feb 25, 2011 9:55 pm

Hey Marcus - thanks - that works, but.. is there a way to use httprequest to point to a script at a specific location, instead of only scripts that macro scheduler "knows"?

My scripts are all saved on a second partition, and the script runs ghost to switch between several different OSes. So I'd have to go back and import the script and create new images for all of them - and if I ever had to change the script for some reason I'd need to do that again.

Whereas if I can, like with msnet, point to a script in D:\macro, then it will work on any of the ghost images that have macro scheduler installed, and I can just change the script on D:\ and still have everything work.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 25, 2011 10:19 pm

No. And Yes.

msNet installs into Macro Scheduler and can only run scripts that are listed within Macro Scheduler.

However, you could create one of these scripts to do something like:

Macro>%macro_file%

And then you could msNet this macro passing the path of the script you want to run in the macro_file variable. You get the idea.

But apart from that the whole point of msNet is to allow you to run macros within a Macro Scheduler installation and for security reasons it is not designed to allow people to run any script anywhere.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BobDDstryr
Junior Coder
Posts: 38
Joined: Fri Oct 22, 2010 2:47 am

Post by BobDDstryr » Sat Feb 26, 2011 12:30 am

Hey Marcus,

You may have a bug in msnet, or maybe I'm just confused?

If I install macro scheduler and msnet on machines A and B and C, and then write a script on machine C - I then just need to copy it to somewhere on machines A + B (D:\macro) and I can run it using the commands:

msnet client_A 6666 D:\macro\script.scp
msnet client_B 6666 D:\macro\script.scp

This has worked out well for me, as I have two machines with different OS images (A and B) , and a third machine (C) that runs a script, telling the two machines what scripts to run for example a script ghost that takes in an os, and then reghosts those machines to that image.

run>msnet client_A 6666 D:\macro\ghost.scp /os=%os%
run>msnet client_B 6666 D:\macro\ghost.scp /os=%os%

I can write the scripts on the third machine, and copy it over, and have things work on the other two machines with no problems - and without ever needing to "import" the scripts into the Macro Scheduler running on those two machines.

The only reason I've been running into an issue now, is that I decided to put in some error checking - so that if for some reason the scripts running the reghost command failed, I wanted to be able to know that from the calling script on machine C, but msnet wasn't giving me a return value.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 26, 2011 6:50 am

I'm sorry, you're quite right. I am the one who is confused. You CAN do that.

So using the HTTPRequest technique so that you can get the response back you would just need to escape the path:

VBEval>Escape("D:\macro\script.scp"),url_script_file

HTTPRequest>http:\\client:6666\%url_script_file%?variable1=X&variable2=Y,,GET,,result
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BobDDstryr
Junior Coder
Posts: 38
Joined: Fri Oct 22, 2010 2:47 am

Post by BobDDstryr » Tue Mar 01, 2011 10:50 pm

Ah! That's just what I was looking for! Thanks Marcus!

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