Mac Help Forums


Reply
Thread Tools Display Modes

Ex Windows IT Tech

 
New Member
Join Date: May 2007
Posts: 3
 
      28th May 2007
I have finally made the switch. I am constantly hacking around on the registries and in DOS on pc's. I am now a dedicated Macbook pro owner. I need to write an applescript to open a program that has to be initialized through Terminal.

I have the following

tell application "Finder"
activate
select window of desktop
select window of desktop
open application file "Terminal.app" of folder "Utilities" of folder "Applications" of startup disk
This is where I get stuck....I had cd "/users/username/"
Then run "./filename.sh"
end tell


Any help is greatly appreciated. Whether it be a mock script, or access to a resource to writing scripts and all the commands usable in Applescript editing.
 
Reply With Quote
 
 
 
 
Ric Ric is offline
Senior Member
Ric's Avatar
Join Date: May 2004
Posts: 4,260
 
      28th May 2007
Hi there and welcome !

try it this way...

Code:
do shell script "/Users/yourusername/Desktop/hello.sh"
Then using your editor of choice...

Code:
#!/bin/sh

osascript -e 'say "[hello from Ric]" using "Zarvox"'

You can use "do shell script" to execute commands ...this is done without opening terminal...

I have attached the test files below...

Make sure you set the correct permissions for the Shell Script to run...

Code:
 chmod u+x /Users/yourusername/Desktop/hello.sh
regards

Ric
Attached Files
File Type: zip hello.sh.zip (223 Bytes, 21 views)
File Type: zip test_Applescript.zip (892 Bytes, 28 views)
 
Reply With Quote
 
Ric Ric is offline
Senior Member
Ric's Avatar
Join Date: May 2004
Posts: 4,260
 
      28th May 2007
Hi there,

here's a bit more for you...

Code:
tell application "Terminal"
	activate
	
	--the commands go here
	do script "pwd" in window 1
	delay 2
	do script "clear" in window 1
	delay 2
	do script "ls" in window 1
	
end tell
I have attached the script below...

regards

Ric
Attached Files
File Type: zip Applescript for terminal.zip (1.6 KB, 29 views)
 
Reply With Quote
 
New Member
Join Date: May 2007
Posts: 3
 
      29th May 2007
Okay. I appreciate your feedback. I get this when I run the following script.

do shell script "/Users/Jeremy/iDine/tinapos.sh"

Exception in thread "main" java.lang.NoClassDefFoundError: net/jmonroe/tpv/forms/JFrmTPV

Any ideas?
 
Reply With Quote
 
Ric Ric is offline
Senior Member
Ric's Avatar
Join Date: May 2004
Posts: 4,260
 
      29th May 2007
Hi there,

'do shell script' will run the 'commands' without opening terminal, depending on what is in your file...tinapos.sh does it need the terminal to open ...for you to interact with it ?

If it does then you will need to use...

Code:
tell application "terminal"
--maybe add in a delay
delay 2
do script "/Users/Jeremy/iDine/tinapos.sh"
end tell
Does tinapos.sh run okay from the terminal directly ?

regards

Ric
 
Reply With Quote
 
New Member
Join Date: May 2007
Posts: 3
 
      30th May 2007
Okay. Thanks again Ric. I entered those lines in to Applescript, however, I get an error. And by the way, if you manually start Terminal and then cd to the directory...and type the .sh command, it works beautifully. Here is the error that I get with the code you gave me....

Exception in thread "main" java.lang.NoClassDefFoundError: net/idine/tpv/forms/JFrmTPV

I get a terminal window that opens, then another terminal window opened titled bash that enters the directory and command...and then that error is displayed in the second terminal window.

Any other suggestions?

Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting 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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MacGuard security software - pop up windows in browser - 'high tech system scanner' spencer UK Macs 0 23rd October 2008 03:08 AM
Latest Joy of Tech... macfizz@gmail.com UK Macs 11 11th March 2006 02:01 PM
Tech problem Anthonyman Programmer Misc 1 22nd April 2004 05:12 PM
Tech note 31 Michelle Steiner Mac 2 7th February 2004 05:31 AM
Tech Tool? HankH Mac 10 7th September 2003 04:05 PM


All times are GMT +1. The time now is 10:54 AM.
Mac-Help.com is an independent website and is not affiliated with Apple Inc.


Welcome!
Welcome to the Mac Help Forums
 


Latest Threads
New book about Steve Jobs << take part in it!
Arjan (1 Hour Ago, 09:37 AM)

Help! Stupid computer is automatically logging me out
Elizaboo (12 Hours Ago, 10:41 PM)

URGENT Help. Crazy talk Mac!
Joeker (13 Hours Ago, 09:42 PM)

PDF Document
yura (22 Hours Ago, 12:13 PM)

Difficulties with internet speed (nothing to do with connection)
sammethh (1 Day Ago, 06:36 AM)

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51