Variable from Before Open script/command output

Resolved

Variable from Before Open script/command output

avatar

Hi.
RDM Free on MacOS, 2023.2.5.1

I am wondering can we access output of the script/macro or command-line from Before Open?
For instance, I want to chain few tasks in order to SSH to an IP address of the remote host by knowing only its hostname (not dns resolvable locally).
So the flow is the following:

  1. Trigger a connection configured with Before Open "Message Prompt". Enter hostname of the machine.
  2. Pass $PROMPT_VARIABLE$ (hostname) gathered from step 1 to Before Open "Command line". Can we actually chain two "Before Open" actions in RDM?
  3. Gather output from "Command line" execution in step 2 and use that result as a variable in SSH Host to connect to (variable would be an IP address).

So far I cannot find any built-in variables which would save output of "Command line", in the similar way like "$PROMPT_VARIABLE$" is working.

Any help is greatly appreciated,

All Comments (3)

avatar

Hi akuriackovskij,

I've tried to think of a way to do what you ask currently, but I couldn't find anything. First, it's not possible to have multiple Before Open events. Secondly, to my knowledge, we don't do anything with the Command Line mode return value.

I think that the simplest way to support what you want would be to modify the "Message Prompt" + "Variable" mode to support a new field for a "modifying script" that would work like the "Command line" mode, but would assume return the value of the Message Prompt is passed as an argument and that it would return something.

Do you think that would cover your case?

Best regards,

Xavier Fortin

avatar

Hi Xavier,

I came to another solution - instead of SSH connection with the Message Prompt I am using "Command Line (External application)" type with "Message Prompt".
I put hostname in the prompt and then passing $PROMPT_VARIABLE$ to an external script as an argument.
External script is simply a bash script which do whatever it needs to do to translate that hostname to an IP (local DNS not possible thus I am querying Netbox with curl), and then bash script invokes rdm template I preconfigured with credentials and few other parameters + "Host" and "Title" arguments like that:

open -a "/Applications/Remote Desktop Manager Free.app" "rdm://open?DataSource=8db309c5-02cb-4d38-b892-66e25a7e7070&Template=38d255ae-759c-4713-9ba6-039d4926edb2&Host=$hostip&Title=$1"


That makes it to open in the RDM in the way I wanted.
It is not ideal because it requires few more lines in bash script (which I was about to use anyway, just not to invoke rdm connections) but I am happy anyway!

avatar

Hello,

We're happy to see that a solution was found.

If the error persists, or you have further questions regarding this, feel free to let us know !

Best regards,