LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-28-2015, 11:57 AM   #1
Wyresider
Member
 
Registered: Aug 2011
Posts: 32

Rep: Reputation: Disabled
/usr/bin/at + ALSA doesn't work?


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?
 
Old 08-28-2015, 12:08 PM   #2
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
I don't know what actually would cause your problem, but you could check if the environment differs between running directly and via at. Put something like `/bin/env > 111` (you can throw in a /bin/id aswell, just for the heck of it) in your script and compare the results.
 
Old 08-28-2015, 12:35 PM   #3
Wyresider
Member
 
Registered: Aug 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Gosh! that was a quick reply! Thank you!

I've done what you suggested. I'm a user, not a guru, so the following makes little sense to me.

From /bin/env > 111

CPLUS_INCLUDE_PATH=/usr/lib64/qt/include
MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man:/usr/local/share/man:/usr/lib64/java/man:/usr/share/texmf/man
HZ=100
HOSTNAME=sid3-14.example.org
SHELL=bash
TERM=xterm
HUSHLOGIN=FALSE
WINDOWID=16777229
OLDPWD=/d/Users/Gordon/Documents/MUSIC/DOWNLOADS/HYPERION/SAMPLERS/2015_SEPTEMBER
ANT_HOME=/usr/share/ant
USER=gordon
XTERM_SHELL=bash
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31; 01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;3 2:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*. EXE=01;32:*.7z=01;31:*.ace=01;31:*.ACE=01;31:*.arj=01;31:*.bz2=01;31:*.cpio=01;31:*.deb=01;31:*.dz=0 1;31:*.gz=01;31:*.jar=01;31:*.lzh=01;31:*.lzma=01;31:*.rar=01;31:*.RAR=01;31:*.rpm=01;31:*.rz=01;31: *.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tlz=01;31:*.trz=01;31:*.t xz=01;31:*.tz=01;31:*.tz2=01;31:*.xz=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:* .aac=01;35:*.AAC=01;35:*.anx=01;35:*.asf=01;35:*.ASF=01;35:*.au=01;35:*.axa=01;35:*.axv=01;35:*.avi= 01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.divx=01;35:*.DIVX=01;35:*.flac=01;35:*.FLAC=01;35:*.gif= 01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2A=01;35:*.m2v=01 ;35:*.M2V=01;35:*.m4a=01;35:*.M4A=01;35:*.m4p=01;35:*.M4P=01;35:*.m4v=01;35:*.M4V=01;35:*.mid=01;35: *.midi=01;35:*.mka=01;35:*.mkv=01;35:*.MKV=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.m p4=01;35:*.MP4=01;35:*.mp4v=01;35:*.mpc=01;35:*.MPC=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MP G=01;35:*.nuv=01;35:*.oga=01;35:*.ogv=01;35:*.ogx=01;35:*.ogg=01;35:*.OGG=01;35:*.pbm=01;35:*.pgm=01 ;35:*.png=01;35:*.PNG=01;35:*.ppm=01;35:*.qt=01;35:*.ra=01;35:*.RA=01;35:*.ram=01;35:*.RAM=01;35:*.r m=01;35:*.RM=01;35:*.spx=01;35:*.svg=01;35:*.svgz=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01 ;35:*.tiff=01;35:*.TIFF=01;35:*.vob=01;35:*.VOB=01;35:*.wav=01;35:*.WAV=01;35:*.wma=01;35:*.WMA=01;3 5:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xcf=01;35:*.xpm=01;35:*.xspf=01;35:*.xwd=01;35:*.XWD=01;35:* .xvid=01;35:
GDK_USE_XFT=1
TERMCAP=vs|xterm|xterm-color|vs100|xterm terminal emulator (X Window System):am:bs:km:co#132:li#58:ct=\E[3k:ue=\E[m:is=\E[m\E[?1l\E>:rs=\E[m\E[?1l\E>:eA=\E)0:as=^N:ae=^O:ac=aaffggjjkkllmmnnooqqssttuuvvwwxx:kI=\E[2~:kD=:kP=\E[5~:kN=\E[6~:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k0=\E[21~:F1=\E[23~:F2=\E[24~:kh=\E[H:kH=\EOw:ks=:ke=:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ms:pt:xn:xo:it#8:RA=\E[?7l:SA=\E?7h:bl=^G:cr=^M:ta=^I:cm=\E[%i%d;%dH:le=^H:up=\E[A:do=\E[B:nd=\E[C:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:DO=\E[%dB:ho=\E[H:cl=\E[H\E[2J:ce=\E[K:cb=\E[1K:cd=\E[J:sf=\ED:sr=\EM:st=\EH:cs=\E[%i%d;%dr:sc=\E7:rc=\E8:ic=\E[@:IC=\E[%d@:al=\E[L:AL=\E[%dL:dc=\E[P:DC=\E[%dP:dl=\E[M:DL=\E[%dM:so=\E[7m:se=\E[m:us=\E[4m:mb=\E[5m:mh=\E[2m:md=\E[1m:mr=\E[7m:me=\E[m:ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:kb=\177:
AUDIODEV=hw:1
T1LIB_CONFIG=/usr/share/t1lib/t1lib.config
XDG_CONFIG_DIRS=/etc/xdg:/etc/kde/xdg
MINICOM=-c on
MAIL=/var/spool/mail/gordon
PATH=/home/scripts:/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/share/ant/bin:/usr/lib64/java/bin:/usr/lib64/java/jre/bin:/usr/lib64/kde4/libexec:/usr/lib64/qt/bin:/usr/share/texmf/bin:.
LC_COLLATE=C
INPUTRC=/etc/inputrc
PWD=/home/gordon
JAVA_HOME=/usr/lib64/java
LANG=en_US
QT4DIR=/usr/lib64/qt
KDEDIRS=/usr
SLACKV=14
ignoreeof=10
XTERM_VERSION=X.Org 7.6.0(281)
XTERM_LOCALE=en_US
SHLVL=7
HOME=/home/gordon
LS_OPTIONS=-F -b -T 0 --color=auto
LESS=-M
LOGNAME=gordon
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig
LESSOPEN=|lesspipe.sh %s
WINDOWPATH=7
DISPLAY=:0
GROFF_TMAC_PATH=/home/lib/groff
G_BROKEN_FILENAMES=1
XAUTHORITY=/home/gordon/.Xauthority
_=/bin/env
and from /bin/id
uid=1001(gordon) gid=102(home) groups=102(home),7(lp),11(floppy),17(audio),18(video),19(cdrom),93(scanner)
 
Old 08-28-2015, 01:08 PM   #4
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
The environment in and of itself isn't that interesting, but rather if there are differences when the script is run by at, or directly. But reading the manpage for at, the environment should be basically kept intact. And since you're still a member of the audio group when run by at (as you should be), I find it weird that you would get permission denied on /dev/dsp.
(Hint: putting "code" in [ code ]text[/ code ] (without the spaces) makes the forum software happier.)
 
Old 08-28-2015, 01:23 PM   #5
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Rep: Reputation: 40
Does he need to be a member of plugdev to use a USB device?
 
Old 08-29-2015, 01:32 AM   #6
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
slacker1337, I don't think /dev/dsp1 would be owned by plugdev, but being member of plugdev is probably not a bad idea anyway.

Wyresider, is the output of /bin/id from a script run by at, or from a terminal? If the latter, I think the problem might be that you're only an implicit member of the audio group (see CONSOLE_GROUPS in /etc/login.defs), which /usr/bin/at doesn't know about. Adding yourself as a proper member (in /etc/groups) should solve it..
 
2 members found this post helpful.
Old 08-29-2015, 04:30 AM   #7
Wyresider
Member
 
Registered: Aug 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
e5150, you have cracked it. Adding myself to audio /etc/group enabled `at' to access /dev/dsp1 ... and it also enabled ALSA under `at'.

It appears that the original error message "... can't open input `hw:1': snd_pcm_open error: No such file or directory" was misleading, and that ALSA and OSS actually had the same problem. Presumably when access to the device was denied, the OSS code in sox gave the correct reason, but the ALSA code in sox assumed that "access failed" meant "doesn't exist"?

Anyway, it works now, using ASLA ... many thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or director irlogo Red Hat 5 03-12-2012 04:38 AM
Error: Cannot find 'ssh-keygen' in '/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin' venu.navat Linux - Software 3 03-08-2012 04:00 AM
[SOLVED] Why doesn't /usr/bin/biff work ? hello.freeman Slackware 2 05-12-2010 07:43 AM
echo $PATH = /home/g3rc4n/bin:/usr/local/bin:/usr/bin:/bin:/usr/games ? i_heart_pandas Linux - Software 7 09-18-2009 08:33 AM
Failed to chck remot comnd executin using shells /usr/bin/ssh and /usr/bin/rsh farnaw4u Linux - Software 2 04-06-2009 12:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration