You may want to describe what problems you are trying to solve. There could be a better way of doing what you want.
MacOS Finder FAQ: Is there a way that I can execute a custom Unix shell script from the Mac Finder? Solution: If you ever want to create a Unix shell script that you can give to someone else so they can double-click it and run it through the Mac OS X Finder, all you have to do is (a) name the file with the.command extension and (b) make it executable. So on a whim, I tried dropping a shell script in my /Library/Scripts folder. Well, it shows up in the menu with a nice shell script icon, and runs fine when I choose it from the menu, without opening up Terminal.app. I'm going to use this to run my X11 apps.
'will purge system memory' doesn't sound right to me. Mac OS X make use off all the memory it can. Any excess memory is used to store copies of applications that you have quit, so if you restore the appl it will load faster.
Run AppleScript action: - code = tell application 'System Events' activate return text returned of (display dialog 'Enter password' default answer ' with hidden answer) end tell. Run Shell Script action: - shell = /bin/bash - pass input = to stdin - code (e.g.) = sudo -S id -u. Workflow will look something like this: Regards, H.
Anyway, here is an applescript with root access which you could invoke from automator:
(*
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
*)
on run
-- Write a message into the event log.
log ' --- Starting on ' & ((current date) as string) & ' --- '
-- debug lines
set unixDesktopPath to POSIX path of '/System/Library/User Template/' https://everas919.weebly.com/blog/vector-illustration-app-mac.
log 'unixDesktopPath = ' & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
https://everas919.weebly.com/blog/stay-awake-app-mac. log 'quoted form is ' & quotedUnixDesktopPath
try
set fromUnix to do shell script 'sudo ls -l ' & quotedUnixDesktopPath with administrator privileges
display dialog 'ls -l of ' & quotedUnixDesktopPath & return & fromUnix
on error errMsg Mac app not working.
log 'ls -l error..' & errMsg
How To Run A Script On Mac
end run
Oct 12, 2014 12:11 PM
How to run a shell script in OS X by double-clicking? (5)
As of OSX 10.10 (Yosemite) and since at least OS X 10.8 (Mountain Lion), the behavior is as follows when you open (double-click) executable scripts from Finder:
[1] Executable means: a script with the executable permission bit(s) set and the calling user - relative to the ownership to the file - therefore potentially being allowed to execute it.
If you use chmod a+x to set all permission bits (which is typical), anyone can invoke it (assuming they're also allowed to read the file based on the read permission bit(s) and the file's ownership).
I have a shell script that has user execution permission on OS X, but when I double click on it, it opens in a text editor. How can I get it to run by double-clicking it?
Mac Run Bash Script
Alternatively, you could create a regular Mac OS X application from your script using Platypus
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |