|
|
script.command - how to kill Terminal after?
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2001
Location: Montrose, CA
Status:
Offline
|
|
Hi,
I wrote a little script to mount a remote hard drive (thanks to commands found on this board!), and now have 2 questions:
1. Anyone know how to kill the finished Terminal.app when my script is finished?
I tried this:
############################
set pid = `ps aux | grep -v grep | grep Terminal | awk '{print $2}'`
if ($pid != "") then
kill $pid
endif
############################
But my variable $pid echo's as empty when the script runs...
2. Anyone know how I can unmount the mounted disk via my script?
Any help with either of these is appreciated!
-Chris
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Sep 2000
Location: France
Status:
Offline
|
|
I think that's because without the appropriate flag, the ps command's output is limited by the width of your current Terminal window. You'll see that if you resize it, the script will work.
The easiest way to solve your problem is to add the -w flag to the ps command, that is type :
ps auwx | grep...
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
To get the PID, (a) don't put spaces between variable name, equals sign, and command, and (b) set is unnecessary if you're using a Bourne shell (as you should for all scripting).
Code:
#!/bin/sh
#
# kill Terminal
#
PID=`ps -auxww | grep Terminal.app | grep -v grep | awk '{print $2}'`
if [ "$PID" != "" ]; then
kill $PID
fi
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2001
Location: Montrose, CA
Status:
Offline
|
|
Victory!
I'm happy to report that the "ps auxw" option worked perfectly.
Thanks!!
-Chris
PS. I use csh for scripting (it's hard to break old habits).
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2003
Location: Sundsvall, Sweden
Status:
Offline
|
|
Or you could just use a much simpler command:
killall Terminal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|