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


Click here to return to the 'Monitor AppleEvents an application sends and receives' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Monitor AppleEvents an application sends and receives
Authored by: bluehz on May 06, '03 11:47:33AM
I am trying to create a small shell script to toggle monitoring AE events off/on but I am having no luck. It tells me:

~/bin/AEmonitor: setenv: command not found
~/bin/AEmonitor: setenv: command not found
~/bin/AEmonitor: setenv: command not found

Can you not use setenv in a shell script?

Pardon the hardwrapped lines in the script - I have no idea why MacOSXHints is doing that to my stuff

#!/bin/sh
#Script to monitor AppleEvents
#
echo -e "Turn AppleEvent monitoring off/on?: \c"
read fname
if [ $fname = off ]; then
setenv AEDebug 0
setenv AEDebugSend 0
setenv AEDebugReceives 0
echo 
"========================================
===================="
echo "AppleEvents Monitoring Disabled"
echo 
"========================================
===================="
else
setenv AEDebug 1
setenv AEDebugSend 1
setenv AEDebugReceives 1
echo 
"========================================
===================="
echo "AppleEvents Monitoring Enabled"
echo 
"========================================
===================="
echo "Launch applications from the terminal using this syntax"
echo ""
echo "         open /Applications/Example/AppName.app &"
echo ""
echo "to monitor the AE for that application."
echo ""
echo 
"========================================
===================="
fi</code>


[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: tjfarrell on May 06, '03 08:54:38PM

Your script is a bourne (sh) shell script (indicated by the
#!/bin/sh on the first line).

The Bourne shell and other shells based on it (zsh, bash, ksh)
use a different way to set environment variables. "setenv" is
appropiate for tcsh and csh shells.

You should use something like the following in the script.


# Export all environment variables.
set -a
AEDebug=1
AEDebugSend=1
AEDebugReceives=1

---
--
T. Farrell



[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: bluehz on May 07, '03 08:02:47AM

Thx! I am still a learning Shell Scripter as you can tell - thats
very useful info. Unfortunately - even after changing the setenv
stuff - its not working as planned. I launch the script, answer
"on" to talk AEmonitoring on - then launch a known
AppleScript type app - open AppName & - but I get no output in
the terminal. Any ideas????



[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: bluehz on May 07, '03 08:04:12AM

Ooops - just noticed I need to be reading the Console for
output.... let me try that...



[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: kerbaugh on May 07, '03 11:22:30AM

Rather than asking the user what he wants to do, it might be easier to simply toggle from on to off or off to on, like so:

#!/bin/sh

if [ -z "$AEDebug" ]; then
export AEDebug=1 AEDebugSend=1 AEDebugReceives=1
else
unset AEDebug AEDebugSend AEDebugReceives
fi



[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: bluehz on May 08, '03 09:00:18AM

thx kerbaugh - I thought about that too. Was also thinking about
building it all into a single launch cmd of the sort you could do
something like:

AEmonitor <appname>

and have the script turn on monitoring, launch the app, and
display the consol (I watch my console in the terminal). Then
shutting it all down when exited.



[ Reply to This | # ]
Monitor AppleEvents an application sends and receives
Authored by: geoffsaulnier on Jun 07, '03 02:43:37PM

export varname = value

will surely only work in bash, ksh or zsh, right? Not in sh.


'course, most ppl use sh because you can virtually guarantee its presence on a system.

G.

---
___<br>
Geoff Saulnier - Mac, *NIX, perl, hack!!



[ Reply to This | # ]