[TxMt] global (project-)command questions [... how to make a command to restart apache and reload a test page in the browser]

Dirk van Oosterbosch, IR labs labs at ixopusada.com
Wed Nov 1 16:40:41 UTC 2006


Hi,

the subject of  this mail might not be very clear, but I'd like to  
make a project command (like Charilaos proposed here: http:// 
lists.macromates.com/pipermail/textmate/2005-October/006283.html )  
that restarts apache in a complicated way (because all the easy ways  
do not work for me) and then loads (or reloads) a given test url in  
the browser (in my case that's Safari atm).

I've come a long way, but still have some small questions:

1. How can a shell variable be used in a osascript oneliner?
Currently I have
   osascript <<APPLESCRIPT
    tell app "Safari" to open location "$MY_TEST_URL"
APPLESCRIPT
which is working, beautifully. It opens the url in $MY_TEST_URL in  
Safari (in the background = without losing the focus in TextMate),  
and when this page is already opened in a window or a tab it just  
refreshes that window or tab.
But if I try to make it into a oneliner the variable replacement fails:
   osascript -e 'tell app "Safari" to open location  
"$IR_LABSITE_TESTURL"'


2. Can a command in one bundle access the support folder of a  
different bundle?
Or can a command from a different bundle be triggered from the current?
I'd like to use the apachectlUsingKeychain.sh shell script that comes  
with the Apache bundle, but is there a way to access that bundle's  
support folder? Or do I have to copy the script to the support folder  
of my own bundle?


3. What does the '-ne'  in  'if [[ $(ps -xp $PPID|wc -l) -ne 2 ]];  
then' do?
Inspired and guided by the Relaunch TextMate command in the TextMate  
bundle, I made the following which works:
     echo "$PWD" | sudo -S apachectl stop
     for (( i = 0; i < 50 && $(echo $(ps -ax | grep [h]ttpd | wc -l))  
 > 0; i++ )); do
       sleep .2;
     done
     echo Apache has stopped
     echo "$PWD" | sudo -S apachectl start
     for (( i = 0; i < 50 && $(echo $(ps -ax | grep [h]ttpd | wc -l))  
< 4; i++ )); do
       sleep .2;
     done
     echo Apache has started again
It works in my few tests, but I'm afraid it will fail when it is  
taking apache too long to stop (or too long to start), so I trying to  
built in a test, just like in the Relaunch TextMate command. But what  
does that '-ne 2' stands for?


Thanks,
dirk





More information about the textmate mailing list