Can I take the result of an Applescript and input into a shell script?

Can I take the result of an Applescript and input into a shell script?

Does Applescript studio have more robust features when it comes to this type of thing?

In a nutshell, my Applescript lets me select a user’s home folder on a mounted firewire drive. From there, I need to copy that home folder to the “loaner” (the local drive of the machine running the script). I can’t seem to get “copy” or “duplicate” to work. I have shell scripts that do this with static named user folders, but now I need the shell script to copy a a non-static named user’s folder that has been selected from my Applescript. Follow?

Yes, it’s possible to use AppleScript variables in a shell script if you are using “do shell script” to run the shell script. Putting that aside for a moment, does this modified version of your script (from the other discussion) do what you need it to do?

set excluded_ to {"Network"}
set volumes_ to (path to startup disk as text) & "Volumes"

tell application "Finder"
	try
		set theList to name of items of alias volumes_ whose name is not in excluded_
	on error
		tell me to return display dialog "No disks available." buttons ¬
			{"OK"} default button 1 with icon 1
	end try
end tell

set theDisk to (choose from list theList with prompt "Please select a disk") as text
set excludedUsers to {"Shared"}

try
	tell application "Finder" to set theUsers to name of (items of folder (theDisk & ":Users")) whose name is not in excludedUsers
on error
	tell me to return display dialog "No user folders available." buttons ¬
		{"OK"} default button 1 with icon 1
end try

set theHome to (theDisk & ":Users:" & (choose from list theUsers with prompt "Please select a home directory") as text)
tell application "Finder"
	delete items of home
	duplicate items of alias theHome to home
end tell

– Rob

Not exactly. Here is the scenario: When we have to send a unit in for repairs, we sut up a student with a loaner unit. currently I have scripts that copy over their home folder, but it’s because their user folders are all called “student”, so all my scripts are not variable, they just use “student”. Per our other discussion, I am now able to select a non-static account (so they are free to setup any account instead of using “student”). So, all I need is when I select their home folder (per our other discussion), I want to copy that home folder to the loaner’s /Users folder, and rename it to “student” and have the shell run my chown scripts. The loaners will still have the mandatory “student” account.

So if a guy’s name is Bob, we select “bob” as our home folder, then copy that to the loaner and rename it as “student” and run chown -R student on the home folder.

It appears your addition to the script is trashing “home”, and I’m not sure what that is exactly trashing.

Now that I look at it, I can see that is pretty much what you were doing with that script. But, I’m confused as to what “home” is, since it was not set as a property.

In the Finder, home refers to the current user’s home folder. Check the result of this.

tell application "Finder" to home as text

The script (in my previous post) will delete the contents of the current user’s home folder and then replace it with the contents of the home folder from the disk that was selected earlier in the script. It sounds like it does not do what you want it to do and I don’t even know if it can run successfully now that I think about it.

– Rob

If you post your shell script, someone can likely show you how to tie everything together with AppleScript. :slight_smile:

– Rob