You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Killing AppleVNCServer with an applescript

Hi, I have a mac at home that I regularly access with VNC from work. AppleVNCServer has a habit of hanging every few days in between sessions. Sometimes if I'm lucky I can get in with logmein and kill the process, but logmein is really flaky from my connection at work for some reason so I can't rely on it. I want to set up a folder within Dropbox using folder actions that will run a script when I drop a file in it. I then want that script to kill the AppleVNCServer process.

I found this ( http://macstuff.beachdogs.org/blog/?p=31) which looks like it should pretty much do what I want. I changed "Finder" in his example to "AppleVNCServer". It seems to identify the process ID (209), but won't kill it. I get the following message:
error "sh: line 0: kill: 65
209: arguments must be process or job IDs" number 1

This is the script:

set app_name to "AppleVNCServer"
set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
if the_pid is not "" then do shell script ("kill -9 " & the_pid)

Does anyone see what's wrong here? I'm only just getting into Applescript. The shell script part is a little over my head...

Thanks,
Sean

G4 Mac Mini, Mac OS X (10.5.8)

Posted on Jan 22, 2010 1:20 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 22, 2010 1:33 PM

I don't understand why you need to do it that way.
just do

try
do shell script "killall AppleVNCServer"
end try
19 replies

Killing AppleVNCServer with an applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.