Retrieving a System Value

I am writing a script that will be run on various OS X machines.

I need to have the path to the current user for some commands in the script.

For example, if the user is ‘myname’ and the startup disk is named ‘myMAChd’,
I’m wondering if there is some system value such that

set mypath to some-system-value

results in ‘myMAChd:Users;myname’

Anybody know what that system value might be? or an alternate way to build the result I need?

TIA

tomp

set thePath to path to home folder
--> Result:  alias "Macintosh HD:Users:jed:"

j

Thanks for the quick reply.

the code compiles, but gives an error upon execution:

the code:
set mypath to path to home folder

the error:
Can’t make alias “Untitled:Users:tcpms:” into a string.

Not sure what to do or what the problem is.

:cry:

Your code works on my system (10.3.5). Does this work for you?

set mypath to path to current user folder

– Rob

whether I use ‘current folder’ of ‘home folder’ for the code I’m getting the same error:

Can’t make alias “Untitled:Users:tcpms:” into a string

I’m also on 10.3.5. Is this a call for applecare?

I would be surprised if AppleCare would offer much relief and I don’t have any idea why the code is failing for you (the error doesn’t make much sense to me).

– Rob

I am not sure why you’re having a problem with this, either. Are you getting this error when just running this one line of code, or are you executing other code afterwards that may be causing the error? Please post all of your code if you are not using just this one line, as it’s probably a conflict with that code rather than this.

You can also try…

set mypath to (system attribute "HOME") & "/" as string
set mypath to (POSIX file mypath) as alias

j

it was the 2nd line of code that caused the problem.

Without the ‘as string’ on the first line, the concatenation in the 2nd line didn’t work and caused the error message. When I stuck in a ‘display dialog myhome’ diagnostic between the 2 lines, of course that didn’t work either. I didn’t realize that ‘path to home’ would be stored as an alias.

Anyhow, the following code gives me what I need:

set myhome to path to home folder as string
set itemalias to myhome & “Reservation Master:VacationMaster”

Now if I can just get the rest of the script to do what I need when I use the itemalias…

Thanks so much for the help! You may be hearing from me again.

Tomp :smiley: