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 > Applications > AppleScript help!

AppleScript help!
Thread Tools
[osX]RTouris
Junior Member
Join Date: Nov 2000
Location: Greece
Status: Offline
Reply With Quote
Sep 1, 2002, 01:42 AM
 
After 10.2 broke compatibility with the "-install" command of dnetc I decided to write a small script and compile it as an application that will run at boot time and launch the thing for me. However after spending a couple of hours browsing through Apple's scripts help pages I still can't figure out how to create a script that will succesfully launch, enter the command and quit the terminal applicaton. Here's what I've done so far:

tell application "Terminal"
activate
with timeout of 2 seconds
do script " /Applications/dnetc/dnetc -quiet "
end timeout
end tell

how can I add a small pause here in order to let the script launch the thing? If I add

quit application "Terminal"

right after the end tell argument above there's not much time given for the script to launch the client in quiet mode and it quits immediately, any ideas?
     
Ibson
Mac Enthusiast
Join Date: Nov 2001
Status: Offline
Reply With Quote
Sep 1, 2002, 03:21 AM
 
Why not try simply doing:
Code:
do script " /Applications/dnetc/dnetc -quiet"
     
Synotic
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Sep 1, 2002, 09:36 AM
 
Originally posted by Ibson:
Why not try simply doing:
Code:
do script " /Applications/dnetc/dnetc -quiet"
Ahem.. small correction

do shell script "/Applications/dnetc/dnetc -quiet"
     
car1son
Mac Enthusiast
Join Date: Nov 2001
Location: Arizona
Status: Offline
Reply With Quote
Sep 1, 2002, 09:50 AM
 
Originally posted by [osX]RTouris:
how can I add a small pause here in order to let the script launch the thing?
FYI, Applescript has a "delay" command. E.g. "delay 10" = pause for 10 seconds.

(As stated you don't need to launch the Terminal to run a shell script from Applescript.)
     
[osX]RTouris  (op)
Junior Member
Join Date: Nov 2000
Location: Greece
Status: Offline
Reply With Quote
Sep 1, 2002, 09:55 AM
 
Success! Thanx for you help guys, this is the final script for anyone who might want to do something similar:

tell application "Terminal"
activate
do shell script " /Applications/dnetc/dnetc -quiet &"
end tell
quit application "Terminal"

The "&" flag is used to stop output to the console, otherwise you'll end up with the client sending output to the console the whole time, which is not a nice thing to watch

There's just one thing now, I've compiled a small application out of it, but at certain points and especially the first time this runs after a restart it crashes...The second time around it works, are there any problems with AppleScript out there?
     
[osX]RTouris  (op)
Junior Member
Join Date: Nov 2000
Location: Greece
Status: Offline
Reply With Quote
Sep 1, 2002, 10:03 AM
 
hehe, I just realised that:

do shell script " /Applications/dnetc/dnetc -quiet &"

also works I guess i wasn't paying too much attention to you guys before

The crash thing persists though, any ideas?
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 11:06 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,