bjoern  committed ba1be01

added check to filter out grep matches when killing Apple's PTP

  • Participants
  • Parent commits ae60714
  • Branches default

Comments (0)

Files changed (1)

 # Apple PTP process blocks USB access to camera by default - kill it
 # pid is first field in whitespace separated line of ps output; 
 #  - sometimes there's a space in front of the pid
-#  - sometimes the grep itself matches
+#  - sometimes the grep itself matches - use [0-9] regex to filter it out
 # the sed line matches: (whitespace)(number)(rest) and prints only (number)
-pid=`ps -e | grep PTP | head -n 1 | sed 's_\([ \t]*\)\([0-9][0-9]*\)\(.*\)_\2_'`
+pid=`ps -e | grep "[0-9] PTP" | head -n 1 | sed 's_\([ \t]*\)\([0-9][0-9]*\)\(.*\)_\2_'`
 kill -9 $pid
 echo "(2) Switch to capture mode by taking an image and throwing it away"