"indecision may or may not be my problem."
jimmy buffett
08.02.05
mac os x has a unix base, and there's quite a lot of back-and-forth integration between the graphical o.s and the command-line one.
for example, you can type 'open -a <application> <file>' in the command line to launch any file into any application, or 'open -e <file>' to open something in the text editor, which is pretty convenient. 'opendiff <file1> <file2>' compares two text files in a gui and allows you to do merges using the FileMerge application.
one thing i couldn't find was a way to run these things in blocking mode. by default these launching programs return after having run the gui app in the background, but sometimes unix scripts want to know when a process ends, and you don't want the launcher to end before the gui program quits.
so i didn't find a general way to do it, but here's a script i endearingly call 'blocken-e' which can be used like 'open -e', but it's blocking, by waiting for TextEdit to finish:
#!/bin/sh
open -e $*
pid=`ps -ax | grep TextEdit | awk '{print $1}' | head -1`
nps=1
while [ $nps -ne 0 ]
do
nps=`ps ax | grep $pid | grep -v "grep" | wc -l`
done
with 'opendiff' its even easier. apparently if you backquote the launcher command it will block until FileMerge is quit, so you do this:
`opendiff file_a file_b -merge outputfile`
in some shells, the non-redirected output will cause trouble, so you can always do this instead:
echo `opendiff file_a file_b -merge outputfile` > /dev/null
if there's a more general way to do this, please let me know...
use filters on the right to see additional content by month or category
content here by guy hoffman .. as seen times since march 2004
Sat, 12 Feb 2005 18:06
Refer your quastion to this guy, Mitz Petel here:
307.forums.ort.org.il@mitzpettel.com
- Oren
Sat, 12 Feb 2005 18:18
who is that and why would he know?
- guy