Injecting a AS variable into shell script

Hi all,

I’m having bit of a problem with the correct syntax for a do shell script.

I have a variable that will find the mount point of a server.

set dfsmount to do shell script (“mount | grep ‘back-data’ | cut -f1 -d\( | cut -f8 -d/”)

Setting this variable works as I’m expecting.

Once the mount point has been determined, I’m attempting to cat a file that exists on that mount point, called .macinfo that will obtain the UUID that is recorded in that file.

If I run this command from command line:

cat /Volumes/dfs/.macinfo | grep UUID= | cut -f2 -d="

I will get the UUID recorded in that file.

I would like this command to run in AS, but it keeps failing on me.

I’ve tried several variations of this command, but am unable to get the results I want:

set net_recorded_uuid to do shell script (“cat /Volumes/” & dfsmount & “/\.macinfo | grep UUID= | cut -f2 -d=”) as string

Can someone see the errors of my syntax?

Thank you in advance!!!

Hi,

the syntax should work, however the as string coercion and the double backslash escape of the dot is not needed.

If the dfsmount variable contains a space character, the whole path must be quoted, which is recommended anyway


set net_recorded_uuid to do shell script ("cat " & quoted form of ("/Volumes/" & dfsmount & "/.macinfo") & " | grep UUID= | cut -f2 -d=")


Thank you Stefan!