ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Find And Run Robot

How to pass a search result to an alias action as $$2

(1/1)

cnewtonne:
Hi all ....
I'm trying to automate logging in to remote hosts via ss and execute shell scripts saved in a local folder on the PC. The final commands looks like this

ssh [email protected]_name my_shell_script.sh

I have 2 variables. First is host_name and a second is my_shell_script.sh

I created 2 aliases ...
1) script_lib which does a 'dosearch' on the folder where scripts are saved
2) exec_ssh defined as 'ssh (.*) (.*) and the pass to the ssh binary 'c:\....\ssh.exe [email protected]$$1 $$2'

In the farr search box I type ....

script_lib get_host_name.sh +exec_ssh

This command passes the get_host_name.sh search hit as $$1 to action alias +exec_ssh. It needs to pass as $$2 since $$1 is the host name. The tool I'm using requires this ordering of arguments.

How can I do this in farr, please.

Thanks

cnewtonne:
Anybody home?

mouser:
Sorry for the delay in replying..

It sounds like you are doing things right with the exec_ssh regex, and that should work passing both arguments.

The tricky part is how you are using the script_lib dosearch using the + thing.. That is getting a little advanced..

I wonder if you could solve it like this:
In the script_lib alias result, do a setuservar command to save the value of $$2 to a temporary variable like "uservar.temp.sshvar2", and then create a new exec_ssh replacement alias that only expects $$1 and then uses "%uservar.temp.sshvar2%" instead of $$2.

Navigation

[0] Message Index

Go to full version