Tuesday, September 29, 2020

#1 2006-10-09 09:19:05 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

calling 'osascript' and getting the right path through the shell

I am having fits trying to get the correct syntax for passing a path to osascript so that it gets through the shell. Here is my command line:

osascript "Server HD:Library:Scripts:Folder Action Scripts:print files.scpt"

I've tried a host of variations with back slashes, quotes and single quotes, all to no avail. I keep getting the error:

0:9: syntax error: A [sic] identifier can't go after this identifier. (-2740)

Can someone give me the correct syntax? TIA.

Offline

 

#2 2006-10-09 09:39:36 am

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4666

Re: calling 'osascript' and getting the right path through the shell

osascript quoted form of "Server HD:Library:Scripts:Folder Action Scripts:print files.scpt"

or

osascript "Server\ HD:Library:Scripts:Folder\ Action\ Scripts:print files.scpt"
escape all spaces.


Mac mini running 10.14.6, 2011 27" iMac as display.

Offline

 

#3 2006-10-09 10:06:15 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

Thanks for the reply.

I'm not sure what you are suggesting with your first suggestion but I'm sure bash doesn't understand 'quoted form of'. As to the second suggestion, that was one of the many variations I tried. It gets the error I posted.

Offline

 

#4 2006-10-09 10:08:57 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

Correction that gets a slightly different error:

0:7: syntax error: A [sic] unknown token can't go after this identifier. (-2740)

Offline

 

#5 2006-10-09 10:31:49 am

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4666

Re: calling 'osascript' and getting the right path through the shell

Hi;

Then you're not telling us enough with this one line. Why are you passing a path this way? In AppleScript that's just a line of text - you're not setting a variable. Why do you need the osascript in the line? Are you executing this from the terminal or as part of a do shell script? We have no context.


Mac mini running 10.14.6, 2011 27" iMac as display.

Offline

 

#6 2006-10-09 10:48:47 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

From a shell script. Sorry I was not clear. I've never used osascript other then from a shell script.

Offline

 

#7 2006-10-09 10:50:39 am

waltr
Member
Registered: 2005-09-13
Posts: 317

Re: calling 'osascript' and getting the right path through the shell

hi gw,

can you post the shell script?  or an approximation?  as adam said, it's hard to figure out what you are trying to do.  post the script, and we can also run it and get the same error.  then we can debug.

cheers.


I use Google or any search engine to find out things I don't know!

Offline

 

#8 2006-10-09 11:00:49 am

johncraig
Member
Registered: 2005-06-08
Posts: 1

Re: calling 'osascript' and getting the right path through the shell

This form will work...

Applescript:

do shell script "osascript " & (quoted form of POSIX path of (choose file))

'choose file' will return an alias to the file you select. If that file is a script it will be executed in the terminal. If you create a script with the following code

Applescript:

return path to me as text

and save it then choose it from the first script it will return the path (in Apple Finder format)

Hope this helps...

John Craig

Offline

 

#9 2006-10-09 11:15:35 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

Thanks for the reply. I got half of it figured out. I was using the '-e' option in the script. By removing that the syntax error went away. Now I just get a no such file or directory error. I think that simplifies things in the sense that now it is a matter of getting the right string past the shell. It does the same thing from the command line but here is the script anyway:

#!/bin/sh

pdfprintdir="/Volumes/Common/Tiiff to PDF/print queue/stage"

pcount=`ls "$pdfprintdir" | wc -l`
if [ $pcount -gt 0 ] ; then
   /usr/bin/osascript "Server\ HD:Library:Scripts:Folder\ Action\ Scripts:print files.scpt"
fi

Offline

 

#10 2006-10-09 11:27:22 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

johncraig wrote:

This form will work...

...

Hope this helps...

John Craig


That just returned what I've already tried (the path was in quotes with no escape of spaces). It resulted in the same error. Thanks anyway, it is a clever idea that I can see other uses for so I filed it away.

Offline

 

#11 2006-10-09 11:55:21 am

gw1500se
Member
From:: Atlanta, GA
Registered: 2003-10-14
Posts: 253

Re: calling 'osascript' and getting the right path through the shell

I got it but I don't get it. Apparently it wants a posix path. Replacing the ':' with '/' fixed it.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)