Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4899 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Is there a way to send a command to Terminal in OSX without using applescript?

I am trying to get a list of SubFolders in a MainFolder, as well as lists of all files in those SudFolders. I will use this list to be able to view PDF files in those folders using a webviewer.

Thank you,

Fed

Posted

Because applescript is slow.

Do you know of another way?

Posted

Because applescript is slow.

Do you know of another way?

This is a broad and inaccurate statement.

Similar to saying "FileMaker is slow".

It depends on knowing details of what you are trying to do and whether you are using appropriate techniques for the task.

Posted

I don't think using AppleScript to call a shell script will be any slower than doing the same thing through Send Event*. It will be much simpler, though

---

(*) assuming it's even possible.

Posted

I've noticed seeing the spinning beachball more often when using AppleScript to do shell commands, especially when using the Calculated AppleScript option, which I believe has to be compiled each time before it runs. Even if the spinning beachball doesn't show for very long, it makes a solution look glitchy and unprofessional compared to not using AS, even with no difference in time elapsed before the script completes.

Anyway, if you're not averse to using plug-ins, the free, cross-platform BaseElements plug-in executes shell commands and does much more:

http://www.goya.com.au/baseelements/plugin

Posted

I've noticed seeing the spinning beachball more often when using AppleScript to do shell commands, especially when using the Calculated AppleScript option, which I believe has to be compiled each time before it runs. Even if the spinning beachball doesn't show for very long, it makes a solution look glitchy and unprofessional compared to not using AS, even with no difference in time elapsed before the script completes.

Anyway, if you're not averse to using plug-ins, the free, cross-platform BaseElements plug-in executes shell commands and does much more:

http://www.goya.com.au/baseelements/plugin

Again you need to describe exactly what you're doing. Do shell is usually way simple and way fast.

Posted

I am getting the feeling from the responses that there is NOT a way to do "Send Events" for Terminal commands in OSX, and I MUST use applescript "Do shell script" instead. Can anyone confirm this?

Thank you,

Fed

Posted

I don't have a definite answer for you, only a few thoughts:

The Send Event script step will not let you choose Terminal as the target application;

The Send Event script step is very poorly documented - in fact, I believe there is no documentation whatsoever that would apply to Mac OS X;

The concept of Apple Events as such is a carry over from the previous Mac OS. Today, if you want to know what events an application will respond to, you need to open its dictionary in AppleScript Editor - and the information is given to you in AppleScript syntax, not as Apple Events codes. That's understandable, because AppleScript is just a wrapper for Apple Events;

AppleScript can call a shell script directly, without requiring Terminal or another application. It can also get the result and return it to Filemaker.

Posted

I cannot get this to work. Do you find anything wrong with the following? I am using it as a calculated applescript:

"do shell script " & Quote ( "mv /Volumes/Medicine/PatientDocuments/ToFile/" & Substitute ( $Name ; " " ; "\ " ) & "/" & Substitute ( $Document ; " " ; "\ " ) & " /Volumes/Medicine/PatientDocuments/Filed/" & Patient Documents::ID )

Posted

I cannot get this to work. Do you find anything wrong with the following? I am using it as a calculated applescript:

"do shell script " & Quote ( "mv /Volumes/Medicine/PatientDocuments/ToFile/" & Substitute ( $Name ; " " ; "\ " ) & "/" & Substitute ( $Document ; " " ; "\ " ) & " /Volumes/Medicine/PatientDocuments/Filed/" & Patient Documents::ID )

1. What isn't working? The shell command is not written properly.

I note that you did not put a trailing slash on the target folder; so the result, if it DID work is that assuming the docID is 1275

/Volumes/Medicine/PatientDocuments/ToFile/Sam Smith/xray analysis.doc

becomes:

/Volumes/Medicine/PatientDocuments/Filed/1275

2. I would suggest doing it more like this but it really is not clear what you are trying to to with the document ID.

set sourcefile to "/Volumes/Medicine/PatientDocuments/ToFile/" & $name & "/" & $document

set targetfolder to "/Volumes/Medicine/PatientDocuments/Filed/" & Patient Documents::ID & "/"

set cmd to "mv " & quoted form of sourcefile & " " & quoted form of targetfolder

do shell script cmd

Posted

"1. What isn't working? The shell command is not written properly.

I note that you did not put a trailing slash on the target folder; so the result, if it DID work is that assuming the docID is 1275"

That is what I am trying to do. I import the jpg into the database, then move and file the original, with a new filename using the serial ID that the database gives it. I get rid of the patient folders to avoid confusion.

I tried what you suggested and it still does not work.

Any further suggestions?

Posted

1. What i suggested works.

2. You were not able to make it work. There is no way for us to know why; until you upload a simplified example file that demonstrates what you have attempted and what you have interepreted.

3. Please be much more specific. You are telling us that you want to take a file "something.jpg" ; and file it as 1275 with no extension.

I doubt that is what you want to do.

Posted

You are right. I forgot the ".jpg"

I added it and I still have the same issue.

I get the following error:

"A unknown token can’t go after this identifier."

Posted

You are right. I forgot the ".jpg"

I added it and I still have the same issue.

I get the following error:

"A unknown token can’t go after this identifier."

Example file please.

Show us what you're doing.

Posted

Of course you get an error: your shell script is not quoted.

do shell script mv /Volumes/Medicine/PatientDocuments/ToFile/Test\ Tester/test.jpg /Volumes/Medicine/PatientDocuments/Filed/26758.jpg

You would have seen this had you followed my advice to inspect the resulting AppleScript visually.

See also:

http://developer.apple.com/library/mac/#technotes/tn2065/_index.html

Posted

I have tried all kinds of different combination of "quoting" the satement, but I cannot find the right way.

Please let me know the right way.

Posted

How about:

Let ( [

source = "/Volumes/Medicine/PatientDocuments/ToFile/" & Patient Documents::Patient Name imported & "/" & Patient Documents::Filename imported ;

target = "/Volumes/Medicine/PatientDocuments/Filed/" & Patient Documents::ID & ".jpg"

] ;

"do shell script " & Quote ( "mv '" & source & "' '" & target &"'" )

)






I haven't tested it, obviously, but the result in your example is:




do shell script "mv '/Volumes/Medicine/PatientDocuments/ToFile/Test Tester/test.jpg' '/Volumes/Medicine/PatientDocuments/Filed/26758.jpg'"

Posted

I tried your suggestion, and now I get th error: "Expected “"” but found unknown token."

Any further ideas. Thanks again.

PatientDocuments.fp7.zip

Posted

You are correct. I thought it was the same thing, but I tried it your way exactly. It works. Thank you so much.

This is why I wanted to avoid applescript. I always get confused and spend many hours trying to do things that should be really easy. I still don't understand why your way works and mine does not.

Tank you again,

Fed

Posted

You are correct. I thought it was the same thing, but I tried it your way exactly. It works. Thank you so much.

This is why I wanted to avoid applescript. I always get confused and spend many hours trying to do things that should be really easy. I still don't understand why your way works and mine does not.

Tank you again,

Fed

But this had nothing to do with applescript. This is about writing accurate shell scripts.

This topic is 4899 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.