Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScript/UNIX Question

AppleScript/UNIX Question
Thread Tools
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Dec 5, 2002, 11:48 PM
 
First off, I'm confusing about paths. Do we still use colons or do we use slashes? "Hard Drive:Applications:AIM" or "/Applications/AIM.app"??
But the real question, that is not really related at all, is...
I'm trying to make an AppleScript app that can start up a unix program, the idea of coarse being that you make the AS a startup item, and it will quickly and easily start unix programs when you boot the machine. The problem is that AS app won't quit. It wait for a reply from the unix app, which is its output, which keeps going until the app quits, so the AS never goes away. I thought this was an easy problem, do I put the unix command line inside a "ignoring application responses" item, but the script ignores the ignore command!! It still waits for the responses from the unix apps!! I'm sure many have tried this and things like this before, someone must have figured it out?
     
Professional Poster
Join Date: Sep 1999
Location: Ottawa, ON, Canada
Status: Offline
Reply With Quote
Dec 6, 2002, 08:52 AM
 
This works in a UNIX shell, so try it in an AppleScript.

Replace your unix command "mycmd args" with

nohup mycmd args

I believe it launches the UNIX commands in the background and returns control right away, it is also immune to shell hangups, so your unix apps won't quit when the applescript ends.

See man nohup for details.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 7, 2002, 04:52 AM
 
For the first question Applescript uses the old way of handling paths. So if you want to convert a pre-OSX styled path to a Unix styled path you have to use the Posix command. Most Applescript commands require the old school form. However on OSX it is very common to call Unix commands which need the Posix form.

To convert from OS9 to Posix do something like the following:

set f to choose file
return POSIX path of f


To do the reverse do the following:

set p to "/etc/passwd"
return POSIX file p


That last bit was a bit tricky to find. You'll probably will find all sorts of hacks that try to do the same thing in weird ways. But the Posix keyword lets you convert both directions.

You can see how you can easily create shell commands with file paths which you then call with the do shell script command.
(Last edited by clarkgoble; Dec 7, 2002 at 05:00 AM. )
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2