1

I have done a ton of searching but wasn't able to find an answer. I am a Python noob. I am having trouble getting the following code to work correctly:

import os
f = open('/home/pi/BGM/sound_config.cfg', 'r')
sound_config = f.read()
f.close()
internet_music = "wget -O - `wget -O - " + sound_config + "' | mpg123 -"
os.system(internet_music)
print "[Internet] Background music playing: " + sound_config

I receive the following error:

sh: 1: Syntax error: EOF in backquote substitution

I believe this is due to the ' character in the command I am trying to initiate (listed below)

wget -O - `wget -O - http://rainwave.cc/tune_in/4.mp3.m3u` | mpg123 -

I know this is probably an easy fix, but it has had me searching all over for the past hour or so.

This code is part of a script I am making to make music play in the background (streamed from the internet) which some later code will kill when other applications get launched.

If anyone could help me I would be very grateful. Thanks!

  • What should be your 2nd backtick is actually a single quotation mark. – Klaus D. Jun 18 '17 at 06:45
  • There is the typo in the Python script (`'` needs to be changed to `\``), but the command itself doesn't look right. When I download `http://rainwave.cc/tune_in/4.mp3.m3u` I get multiple URLs intermixed with `#`-style comments, which won't work as an argument to `wget`. What are you trying to do? – tom Jun 18 '17 at 06:51

1 Answers1

1

You are missing a ` here:

sound_config + "'

Last character looks like ' instead of `.

hurturk
  • 5,214
  • 24
  • 41
  • We all been there, have a look at string [formatting](https://stackoverflow.com/q/5082452/1233686) to make it easier to read. – hurturk Jun 18 '17 at 06:56