|
|
File that does a Terminal command?
|
|
|
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
Can anyone tell me how to make a file that I can double click on and it will do a Terminal command? I'd prefer to stay away from AppleScript. Isn't this what a shell script does? I tried modifying an existing one, but it doesn't seem to like be clicked on :/ Thanks in advance.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: oakland, ca usa
Status:
Offline
|
|
check this out (xml below) - just change the <string> below the key 'ExecutionString' to point to your shell script.
or maybe i heard you could name a shell script with a '.sh' extension for double clicking heaven.
but you can save the text below (or save any custom terminal) and then edit it in text editor in the 'ExecutionString' string...just be sure to save it as a '.term' - and be sure to keep the return in there (before the '</string>,' if you want it to execute.
------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>WindowSettings</key>
<array>
<dict>
<key>AutoFocus</key>
<string>YES</string>
<key>Autowrap</key>
<string>YES</string>
<key>Bell</key>
<string>NO</string>
<key>BlinkCursor</key>
<string>NO</string>
<key>Columns</key>
<string>80</string>
<key>CursorShape</key>
<string>0</string>
<key>CustomTitle</key>
<string>Terminal</string>
<key>DisableAnsiColors</key>
<string>NO</string>
<key>DoubleBold</key>
<string>YES</string>
<key>ExecutionString</key>
<string>top -u -s 5 10
</string>
<key>FontHeightSpacing</key>
<string>1</string>
<key>FontWidthSpacing</key>
<string>1</string>
<key>IsMiniaturized</key>
<string>NO</string>
<key>Keypad</key>
<string>NO</string>
<key>Meta</key>
<string>-1</string>
<key>NSFixedPitchFont</key>
<string>Monaco</string>
<key>NSFixedPitchFontSize</key>
<real>1.000000e+01</real>
<key>Rows</key>
<string>19</string>
<key>SaveLines</key>
<string>10000</string>
<key>Scrollback</key>
<string>YES</string>
<key>Shell</key>
<string></string>
<key>ShellExitAction</key>
<string>1</string>
<key>SourceDotLogin</key>
<string>YES</string>
<key>StrictEmulation</key>
<string>NO</string>
<key>TerminalOpaqueness</key>
<real>8.500000e-01</real>
<key>TextColors</key>
<string>0.990 1.000 0.018 0.000 0.000 0.000 0.796 0.594 0.352 0.796 0.594 0.352 0.000 0.000 0.000 0.990 1.000 0.018 0.453 0.464 0.452 0.696 0.696 0.696 </string>
<key>TitleBits</key>
<string>3</string>
<key>Translate</key>
<string>YES</string>
<key>WinLocULY</key>
<string>1178</string>
<key>WinLocX</key>
<string>951</string>
<key>WinLocY</key>
<string>0</string>
</dict>
</array>
</dict>
</plist>
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Just give the file the ".command" filename extension. then you can double click on it to open and run it in the terminal.
|
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
I'm not sure why you want to stay away from AppleScript. It's so easy to use and doesn't need to open Terminal to do it.
Alternatively, you could install Script Menu and you can run shell scripts from that.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: oakland, ca usa
Status:
Offline
|
|
yeah, save this applescript as an application (replacing the cat command with your own shell script)...
on run
do shell script "/bin/cat /etc/motd"
end run
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
If you just want to run a command with no arguments, you can just give the command a creator code of trmx. For example, you could set /usr/bin/top's creator code to trmx, and then you could double click on it and it would bring up the Terminal, with the top command running.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
The .command suggestion seems perfect, and actually works, but it has to launch the Terminal? I just want it to do its function and that's it, not have to launch anything extra.
As for AppleScript, I am already very fluent with it, enough to know that I don't want an applet launching when this is meant to match the speed of opening a folder and that I don't want to have to make a background only AS-S app because it'd be no doubt even slower. Also, I need it to be a file (it will be faked as a folder), so a menu item won't do.
I have yet to try the XML idea (I can get rid of all that extra crap right?.. TerminalOpaqueness??) and the creator type one, but I will very soon.
Thanks for all your suggestions.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: oakland, ca usa
Status:
Offline
|
|
i don't think you'll care much for the xml hack - it's just a custom terminal set that executes the command on launch. it's an example.
i think the only transparent double-click method for invoking shell scripts, perl scripts, etc. currently available is via applescript, or an actual cocoa/carbon application...you want some kind of shell wrapper app-maker (save as shell script application).
i'm pretty used to unix, so i launch my shell scripts in the shell.
this runs fast (until i try to launch it as an applet, then it is indeed slow to launch):
set foo to do shell script "curl -s <A HREF="http://www.stuped.com/cgi/remote_addr.cgi"" TARGET=_blank>http://www.stuped.com/cgi/remote_addr.cgi"</A>
display dialog foo
what are you trying to run?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Belgium
Status:
Offline
|
|
I am searching for an app or script that excecutes this command when I start OSX; sudo ipfw add 0 deny udp from any to any 2222 and
sudo ipfw add 0 deny tcp from any to any 3464, it aks for your password and it would be nice if this was all automized. These commands block a network port so that I can use MS Office on more than one mac at the same time. I have no experience with shell scripts or applescripts so please keep it simple
TIA
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
If you only want it to run once, and don't want to have to run it yourself, how about making it a StartupItem? That way you don't even have to think about it.
<font face = "courier">
sudo -s
mkdir /Library/StartupItems
mkdir /Library/StartupItems/ShareOffice
</font>
Then
<font face = "courier">
cd /Library/StartupItems/ShareOffice
pico ShareOffice
</font>
In that file, enter the text:
<font face = "courier">
#!/bin/sh
#Startup the common code
. /etc/rc.common
#Block Office's license protection
ConsoleMessage "Enabling Shared Office v.X"
ipfw add 0 deny udp from any to any 2222
ipfw add 0 deny tcp from any to any 3464
</font>
Press ctrl-O, then ctrl-X to save and exit. Then make another file:
<font face = "courier">
pico StartupParameters.plist
</font>
And in that file, type:
<font face = "courier">
{
Description = "Enable Sharing Office v.X on the network";
Provides = ("ShareOffice");
Requires = ("Network");
OrderPreference = "Last";
Messages =
{
start = "Enabling Sharing of Office v.X";
stop = "Disabling Sharing of Office v.X";
};
}
</font>
and command-O command-X again.
That should work.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Belgium
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
Originally posted by [email protected]:
<STRONG>this runs fast (until i try to launch it as an applet, then it is indeed slow to launch)</STRONG>
Which of course is the problem.. :/ I guess I'll write a background Cocoa app that does what I want after reopening.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
What is it you're trying to do, Synotic? Maybe folks can come up with some other approaches if you let on to your secret plan...
|
|
|
|
|
|
|
|
|
Ambrosia - el Presidente
Join Date: Sep 2000
Location: Rochester, NY
Status:
Offline
|
|
Originally posted by Synotic:
<STRONG>As for AppleScript, I am already very fluent with it, enough to know that I don't want an applet launching when this is meant to match the speed of opening a folder and that I don't want to have to make a background only AS-S app because it'd be no doubt even slower. Also, I need it to be a file (it will be faked as a folder), so a menu item won't do.</STRONG>
In that case, I suggest you write yourself a shell or Perl script. Both are quite easy to learn.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|