How can I run a shell script on multiple different computers with the same code? If I have it run from
/users/'my name'/desktop/etc.
then it won't work when I use it on a different computer, because the user name will be different. Is there any way to run it directly without going through the user directory?
Best Answer
The AppleScript command I think you're looking for is:
or
But that would return an HFS path and the code you posted is a POSIX Path so you could change it to:
As stated in the comment there is
$USER
for the terminal and per memory you can still call it in AppleScript with something like:If
path to desktop folder
doesn't work you can try justpath to desktop
.Edit
Addressing the comment. I was taught HFS path and alias path were the same, will make it another question for clarity.
Building the path
as text
is a habit when concat strings or if I was going to take the path and call it later in ado shell
. For example:in Script Debugger returns an HFS path. When you combine a directory as it was shown in the OP's question a compiling error occurs with:
and a
when I've called paths using
path to
I've had to write them as:I was unfamiliar to
short user name of (system info)
andpath to home folder
but that's good to know. One issue with the question is the OP marks it with terminal and AppleScript so the solution is somewhat complicated.