Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'How to do arbitrary commands' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to do arbitrary commands
Authored by: _merlin on Dec 23, '01 03:01:16PM
Here's a little script that will take the same syntax and let you use an arbitrary command. Gotta love osascript ;-)
#! /bin/sh

if [ $# -le 1 ] ; then
echo "Usage: `basename $0` title command"
exit 0
fi

printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
"set the WindowTitle to \"$1\"" \
"set the CommandLine to \"$2\"" \
"" \
"set the CommandLine to the CommandLine & \" ; exit\"" \
"tell application \"Terminal\"" \
" do script with command the CommandLine" \
" get windows" \
" set the TerminalWindows to the result" \
" repeat with i from 1 to the count of the TerminalWindows" \
" set the CurrentWindow to item i of the TerminalWindows" \
" if the name of the CurrentWindow is equal to the CommandLine then" \
" set the custom title of the CurrentWindow to the WindowTitle" \
" end if" \
" end repeat" \
"end tell" \
| osascript


[ Reply to This | # ]
Posted working version of this script
Authored by: evands on Dec 24, '01 01:23:34AM

is available from my iDisk at:
http://homepage.mac.com/evands/

Just spent a while figuring out what had gotten messed up in the posting and decided to share with anyone who wants...



[ Reply to This | # ]
Corrected original...
Authored by: robg on Dec 25, '01 09:27:15AM

I believe I have now corrected the original posted version, so it should work with a copy and paste.

-rob.



[ Reply to This | # ]