Oops; the output of ps begins with a space, so the 2nd to last line needs to be either
pid=`ps ax | grep -m1 -e '[X] .* vt'$console | cut -d' ' -f 2`
or perhaps the more-resilient
pid=`ps ax | grep -m1 -e '[X] .* vt'$console | sed -re 's/[^0-9]*([0-9]+).*/\1/'`
which is what I'm currently using.
Oops; the output of ps begins with a space, so the 2nd to last line needs to be either
pid=`ps ax | grep -m1 -e '[X] .* vt'$console | cut -d' ' -f 2`
or perhaps the more-resilient
pid=`ps ax | grep -m1 -e '[X] .* vt'$console | sed -re 's/[^0- 9]*([0- 9]+).*/ \1/'`
which is what I'm currently using.