I can't record audio via `at'. Can someone explain what is happening?
System is Slackware 14.0 64; audio device is a USB D2A/A2D; ~/.bashrc contains "AUDIODEV=hw:1".
Usually, I record (from LP, tape, tuner, mic or whatever) by
rec -r 44100 outfile.wav # with or without "trim 0 mm:ss"
(or something like that -- exact parameters may include channel specs for mono microphone or whatever).
I wanted to record something at a particular time, so I ran (names and times are generic)
at -f at.txt 18:00
where at.txt contained
rec -r 44100 news.wav trim 0 10:00 2>222
The script works fine if executed directly, but after `at' ran it, syserr file 222 contained
ALSA lib pcm_hw.c:1401_snd_pcm_hw_open) Invalid value for card
rec FAIL formats: can't open input `hw:1': snd_pcm_open error: No such file or directory
(If you see an emoticon in the above, it's an arsifact of bad webware -- the text is colon_openparentheses.)
I tried various flavours like
sox -r 44100 -t alsa hw:1 news.wav trim 0 10:00 2>222
but with identical results.
Then I thought ... what about OSS? I've not used OSS since way back, and didn't know if it even existed on my current system, or if it was now just an ALSA-emulation of it, but I had a go. Executed directly,
sox -r 44100 -t oss /dev/dsp1 news.wav trim 0 10:00 2>222
worked perfectly (and exactly as "rec -r 44100 outfile.wav"), but under `at' it gave
sox FAIL formats: can't open input file `/dev/dsp1': Permission denied
BAH! Permission wan't denied a minute ago (direct execution). So I took a non-volatile copy of /dev/dsp1, ran "chmod a+rw" on it, pointed the job at the copy, and BINGO -- everything worked perfectly.
But a workaround like that, copying dev nodes and depending on obsolete interfaces, ain't exactly satisfactory (or future-proof). Can someone please tell me (a) what has been happening? and (b) what's the "correct" way to do it?