How to pass variable to Applescript

I am trying to pass a variable from a list of servers to the end of a ssh login command.

User uploaded file

User uploaded file


I want the "server" to be the one that was picked from a list. The variable is being picked up correctly, I just can't get it to display after the "ssh root@".


Any help would be appreciated.



Code:

tell application "Terminal"

activate

set currentTab to do script {"ssh root@"server";"}

end tell

Posted on Oct 27, 2015 7:54 PM

Reply
5 replies

Oct 27, 2015 8:18 PM in response to teknikk7

You need to restore the default Applescript command. The input parameter is the passed information.

Everything is passed down the chain and strung together and passed as a list in the "input" parameter.

That is why you have two "Silver Spring" items in the list.

I can't remember which order they show up, so you'll have to check that, but I assume the last passed parameter is the one at the end of the list.

To get that item you can use "last item of input"

If it turns out to be the first in the list, then first item of input.


You can interrupt the passing chain by right-clicking on the connection arrow between actions and choosing Ignore Input.

Oct 28, 2015 11:49 AM in response to Barney-15E

And, you haven't used the server name which is an item in the input variable.


And currentTab is not an element of the Terminal dictionary.


And you don't need a View Results action as you can just click the Results button at the bottom of each action.


Try this snippet inside the Run handler:

tell application "Terminal"

do script ("ssh root@" & first item of input) in selected tab of window 0

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to pass variable to Applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.