Unix script

Ok, firstly,
Thank you MacScript and anyone who helps me on this, MacScript has done so much and needs more thanks

Now Secoundly,
I want to have an applescript that will read my unix command input (ie: ps -x, top, etc.) and then print the results.
so basic you type in any command/thing and press return, the applescript then shows you the result, if thats not possible, then being to
able to have the command excuted and displayed in Terminal would be great.

There is also 2 more questions I have (I don’t like filling up space in forums),
1-What are comma marks in applescript, I need the comma’s to open a javascript URL:

property target_URL : "javascript:alert("Thanks MacScripter")"

open location target_URL

Except try and run this and it won’t let you because of the comma’s in there.

2-I want to get applescript to display (Full screen would be excellent) a picture of a chosen file (so I just click run and it opens the image).

Thanks again, I can’t say that enogh

Model: MacBook Pro
Browser: Safari 419.3
Operating System: Mac OS X (10.4)


Some commands like ‘top’ have continuous output. To get one result, you could use the l option.

do shell script "top -l  1 > ~/Desktop/top.txt"

But, I suspectt that you’re trying to do something else.


So you would do something like this.

display dialog "Enter a command:" default answer ""
set t to text returned of result
do shell script t

You would need to add a lot of error checking.


Hi, lunixninja.

It’s actually better if you post unrelated questions as separate threads with their own subject lines. That makes it easier for other people and makes it more likely that all the questions will be answered. Someone who knows the answer to an ‘open location’ question but doesn’t know any Unix might not read a thread called “Unix script”. Similarly, someone else with the same ‘open location’ problem won’t look for the answer here.

Presumably, by “comma’s” you mean “quotes”.

You can “escape” quotes in strings by placing a backslash before each one.

property target_URL : "javascript:alert(\"Thanks MacScripter\")"

open location target_URL

This still doesn’t do anything, but at least it compiles. I don’t think ‘open location’ does JavaScript URLs. AppleScript has its own dialogs and alerts. But you can display a JavaScript alert in Safari, which has a ‘do JavaScript’ command.

property js : "alert(\"Thanks MacScripter\")"

tell application "Safari"
	do JavaScript js in front document
end tell

Thanks guys, or should I do,

property js : "alert(\"Thank you guys so much\")"

tell application "Safari"
	do JavaScript js in front document
end tell