Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatenate a string and a variable into a string in applescript

I have to write an Applescript to automount a folder depending on the user. Applescript Editor throws this error.

A end of line can’t go after this identifier.

Here the portion of the script that is throwing the error.

try
    set short_name to do shell script "whoami"
    set path to "afp://fileserver.local/Faculty/" & short_name
    mount volume path as user name short_name
end try
like image 484
jeremyjjbrown Avatar asked Aug 26 '11 20:08

jeremyjjbrown


People also ask

How do you concatenate strings and variables?

Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.

How do I concatenate a variable to a string in bash?

The += Operator in Bash Bash is a widely used shell in Linux, and it supports the '+=' operator to concatenate two variables. As the example above shows, in Bash, we can easily use the += operator to concatenate string variables.

How do I concatenate a string and a variable in Perl?

In general, the string concatenation in Perl is very simple by using the string operator such as dot operator (.) To perform the concatenation of two operands which are declared as variables which means joining the two variables containing string to one single string using this concatenation string dot operator (.)

How do I concatenate two characters to a string?

C++ has a built-in method to concatenate strings. The strcat() method is used to concatenate strings in C++. The strcat() function takes char array as input and then concatenates the input values passed to the function. In the above example, we have declared two char arrays mainly str1 and str2 of size 100 characters.


1 Answers

path can't be a variable name.

try
    set short_name to do shell script "whoami"
    set p to "afp://fileserver.local/Faculty/" & short_name
    display dialog p
end try

Works fine.

like image 190
Bertrand Marron Avatar answered Oct 19 '22 15:10

Bertrand Marron