Mod: choose user

  • Distribute selected tracks to more than one remote user.

The first two rsync scripts are intended to run in the background with launchd so there can be no user-interaction (well, I suppose a dialog could pop out of nowhere every launchd cycle and ask for user input but that's rilly oogly). However, the current script can easily accomodate a choose from list dialog whereby one or more of several remote users can be selected as recipients. (Or,a list of remote users could be looped through.)

Make these property declarations at the very beginning of the script:

property listOfUserNames : {"cleanuser", "mamauser", "sonicuser"}
property listOfHostIPs : {"", "", ""}

Supply the usernames and corresponding IP addresses for the users you want to choose from. The order of the items in the listOfHostIPs list must correspond to the order of items in listOfUserNames. Each of these users should have been given the ssh-keygen treatment.

Here is the choose from list routine, which will set the remUserName, remHostIPAddr and remAddr variables:

set chosenUsername to (choose from list listOfUserNames) as text

if chosenUsername is "false" then return

repeat with i from 1 to (length of listOfUserNames)
	if chosenUsername is (contents of item i of listOfUserNames) then
		set remUserName to (contents of item i of listOfUserNames)
		set remHostIPAddr to (contents of item i of listOfHostIPs)
		set remAddr to (remUserName & "@" & remHostIPAddr) as text
		exit repeat
	end if
end repeat

Use this routine instead of the hard-coded remUserName, remHostIPAddr and remAddr section. This could also be adapted such that a multiple selection of users or, by foregoing the choose box altogether, all the users loop through the main routine re-written as a subroutine.

Site contents © 2001 - 2021 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not interrupt the one doing it.