readcd 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/rc
  2. cdrom=/dev/sdC1
  3. switch($#*){
  4. case 3
  5. starttrack = `{echo $1 - 1 | hoc}
  6. endtrack = `{echo $2 - 1 | hoc}
  7. desttrack = $3
  8. case *
  9. echo Usage readcd starttrack endtrack desttrack
  10. }
  11. if(test -e /mnt/cd/ctl){
  12. echo -n ingest >/mnt/cd/ctl >[2]/dev/null
  13. }
  14. if not {
  15. if (~ $cdrom '') cdfs
  16. if not cdfs -d $cdrom
  17. }
  18. >/tmp/readcd
  19. >/tmp/map
  20. cat /mnt/cd/ctl
  21. sed 1q /mnt/cd/ctl | rc
  22. echo $starttrack $endtrack $desttrack | awk '{
  23. start = $1
  24. finish = $2
  25. dest = $3
  26. print "read cd tracks " start "-" finish " starting at " dest
  27. for (i = start; i <= finish; i++) {
  28. cmd = sprintf("ls -l /mnt/cd/a%3.3d | awk ''{print $6}''>>/tmp/readcd", i)
  29. system(cmd)
  30. getline x<"/tmp/readcd"
  31. sec = x/44100/4
  32. min = sec/60
  33. sec = sec%60
  34. printf("track {\n\t\n\tfile {%3.3d}\n\ttime {%d:%2.2d}\n}\n",i+dest-start,min,sec)>"/tmp/map"
  35. }
  36. for (i = start; i <= finish; i++) {
  37. cmd = sprintf("/bin/games/pacenc /mnt/cd/a%3.3d %3.3d",i,i+dest-start)
  38. print cmd
  39. system(cmd)
  40. }
  41. }'
  42. echo eject >/mnt/cd/ctl