Guest User

doug

a guest
Oct 23rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #! /bin/bash
  2. # Wait for a CD to be inserted then copy the contents
  3. #
  4. echo "CD copy, press <ctrl>C to exit"
  5. echo "Looking for disk..."
  6. #
  7. # Go into a continuous loop always looking for a new CD
  8. while :
  9. do
  10. ####### Get the mount point of /dev/sr0 out of the mounts file
  11. TEST=$(grep /dev/sr0 /proc/self/mounts)
  12. ####### If it doesn't exist, loop until it does with 1 second pause
  13. if [ "$TEST" == "" ]; then
  14. echo -ne "."
  15. sleep 1
  16. else
  17. echo
  18. ############### Got it! Need to strip the mount point out of the string
  19. TEST2=${TEST:9}
  20. set $TEST2
  21. TEST=$1
  22. ############### Do the copy process for the disk we found
  23. echo "Copying from $TEST"
  24. cp -vr $TEST/* ~/Music/
  25. ############### Eject the CD with suitable pauses to avoid any buffer problems
  26. sleep 1
  27. eject /dev/sr0
  28. sleep 2
  29. fi
  30. ######## Still looping! Go back and wait for another CD!
  31. done
  32. exit()
  33.  
  34. Copying from /run/media/doug/Blues\040mp3s\040Vol\0409
  35. cp: cannot stat '/run/media/doug/Blues\040mp3s\040Vol\0409/*': No such file or directory
  36. Error unmounting block device 11:0: GDBus.Error:org.freedesktop.UDisks2.Error.DeviceBusy: Error unmounting /dev/sr0: Command-line `umount "/run/media/doug/Blues mp3s Vol 9"' exited with non-zero exit status 32: umount: /run/media/doug/Blues mp3s Vol 9: target is busy
  37. (In some cases useful info about processes that
  38. use the device is found by lsof(8) or fuser(1).)
  39.  
  40. eject: unmount of `/run/media/doug/Blues mp3s Vol 9' failed
  41.  
  42.  
  43. Copying from /run/media/doug/Blues\040mp3s\040Vol\0409
  44. cp: cannot stat '/run/media/doug/Blues\040mp3s\040Vol\0409/*': No such file or directory
Advertisement
Add Comment
Please, Sign In to add comment