Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 9, 2007, 06:07 AM   #1
qpple
macrumors newbie
 
Join Date: Sep 2007
Applescript return argument given in command line

Hello I'm trying to make a simple script. The applescipt is called from the command line as an ordinary shell script : admin$ ./scipt.app "hello"

And the Applescript is looking like this :

set message to system attribute "$1"
tell application "Finder"
display dialog message
end tell

Now my problem is that the dialog returns an empty message, where there should be "hello" displayed. Is this something that can be done with an Applescript ? I know that I can use osascript but that isn't an option.

I hope there is a simple sollution.

Qpple
qpple is offline   0 Reply With Quote
Old Sep 9, 2007, 03:56 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Why isn't osascript an option? You're already at the command line.

osascript works fine. I couldn't get your method working when you run the .app directly.

Code:
on run message
	tell application "Finder"
		display dialog message
	end tell
end run
Run it like so:

$ osascript script.scpt hello
kainjow is offline   0 Reply With Quote
Old Sep 11, 2007, 08:44 AM   #3
qpple
Thread Starter
macrumors newbie
 
Join Date: Sep 2007
Quote:
Originally Posted by kainjow View Post
Why isn't osascript an option? You're already at the command line.

osascript works fine. I couldn't get your method working when you run the .app directly.

Code:
on run message
	tell application "Finder"
		display dialog message
	end tell
end run
Run it like so:

$ osascript script.scpt hello
Let me elaborate why I'm trying to do:
In Apple Remote Desktop (ARD) there is an option to perform a script when a task is complete (in preferences > tasks > "Enable task notification script"). The option calls a shell script with 2 arguments/parameters classname and execution state.
Now I want to create an AppleScript that can accept those 2 arguments that are passed on via the command line and do something with them in the AppleScript. As you can see the osascript isn't an option because I can't alter ARD.
There is an option but not that beautiful because there will be 2 files needed. One shell script file wich redirects the parameters to an AppleScipt with osascript.

Now my question is : Is this possible ?

I would like to be able to call an AppleScript like this : $ ./script.scpt hello

Qpple
qpple is offline   0 Reply With Quote
Old Sep 11, 2007, 09:28 AM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by qpple View Post
There is an option but not that beautiful because there will be 2 files needed. One shell script file wich redirects the parameters to an AppleScipt with osascript.
This is what I'd do. Just have a shell script that redirects the arguments to osascript.
kainjow is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
APM library in command line utility jerrywickey Mac Programming 19 Jul 30, 2010 06:43 AM
List partitions in command line Tex-Twil OS X 3 Sep 17, 2009 11:31 AM
Terminal - How to access files written with space in command line? honorfield Mac Applications and Mac App Store 2 Sep 13, 2009 09:06 PM
Formatting OSX in command line Ghandi Mac Basics and Help 2 Sep 20, 2005 05:21 PM
HELP! Stuck in Command Line Mode at Startup! excalibur313 Mac Applications and Mac App Store 1 Jan 21, 2004 09:47 PM


All times are GMT -5. The time now is 05:35 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC