I was wanting to run an applescript to tunnel to my itunes server using my rsa key from a usb drive. My goal was to run the line until the process is killed by clicking ok. I tried to figure this out by reading the apple technotes 2065 Technical Note TN2065: do shell script in AppleScript, but when I added in lines four and five, the number of the process created on the system did not match the value of pid.
do shell script "ssh -l /Volumes/Mac/.ssh/id_rsa firstname.lastname@example.org -N -f -L 3689:127.0.0.1:3689 &> /dev/null & echo $!" set pid to the result do shell script "renice +20 -p " & pid display dialog "End" buttons ["OK"] if button returned of result is "OK" then do shell script "kill " & pid end if