I am trying to call this command:
avconv -i '/opt/music/Smooth Criminal.mp3' -ac 1 -ar 22050 -b 352k -f wav - | /opt/pifm/bin/pifm - 98.3 with my own paths.
In the terminal it works like a charm but when I run it through the python subprocess module I get this error:
Traceback (most recent call last):
File "alarmclock.py", line 23, in <module>
File "alarmclock.py", line 9, in play_files
call(["sudo avconv -i '/home/pi/Files/alarm.mp3' -ac 1 -ar 22050 -b 352k -f wav - | sudo '/home/pi/Files/pifm' - 105.9"])
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
OSError: [Errno 2] No such file or directory
I am sure the paths I have a real files and I know that because it works perfectly from terminal. For some reason the call method is not liking this line. I tried all sorts of combinations of quotes to make it know which were the paths, etc but I have not been able to get it to work.
From Python I am calling it like this:
call(["$"]) where $ is the above command. If I change those quotes to single quotes it gives a syntax error:
File "alarmclock.py", line 9
call(['avconv -i '/home/pi/Files/alarm.mp3' -ac 1 -ar 22050 -b 352k -f wav - | sudo /home/pi/Files/pifm - 89.9'])
SyntaxError: invalid syntax
I cannot see anything wrong with the syntax there. Any ideas?
UPDATE: I tried suggestion in comments bellow to to switch both but that gave the same error. Any Ideas?