Modify $HOST$ variable before open

Modify $HOST$ variable before open

avatar

Hi!
I have use-case where I have an SSH entry. That SSH entry has Before Open event to prompt for the hostname to connect to. Then $PROMPT_VARIABLE$ is used in Host field in General section.
All that is fine... when you have working DNS. I don't :)

I have a Netbox (IPAM system) to which I can do an API call with the curl bash command to retrieve IP of the hostname.

Is there any way to do the following:

  • Get prompted to input hostname
  • Make an API call to Netbox with $PROMPT_VARIABLE$ argument
  • Use returned value to override Host variable in SSH entry


I have a dirty workaround which I don't like - since I have different credentials for different subset of hosts I can use the following:

  • Command line entry in RDM which prompts for the hostname and run a bash script "myscript.sh $PROMPT_VARIABLE$"
  • myscript.sh has commands to make an API call to Netbox to get an IP ($hostip below)
  • Then myscript.sh invokes RDM Template via command open -a "/Applications/Remote Desktop Manager.app" "rdm://open?DataSource=dad2.....Template=$templateid&Host=$hostip&Title=$host"

But that is hard to maintain because for every connection with different creds I need to have a separate RDM Template, and also additional logic in bash script to use that specific Template when connecting to specific hostnames....

So my question is, how on MacOS to overwrite Host variable with something what can be returned from a command line (or from external bash script?)

Thanks!

All Comments (3)

avatar

Hi,

I would like to confirm that I understand your problem correctly.

You are looking to make an API call using the hostname you've provided,
the API will then return the corresponding IP address,
which you would like to use as the host variable. Is that correct?

Best regards,

Gabriel Dufresne

avatar

Hi Gabriel,

Yep that is correct!
Thanks.

avatar

hi,

At this time, we do not have a solution available to achieve what you're asking for. However, I have opened a ticket to investigate this use case.
If you have any additional questions or need further assistance, please don't hesitate to reach out.

best regard,

Gabriel Dufresne