unexpected token `;'

B

bbarbero

Hello to all!

I am struggling with a script in python for a while now, and decided
to look for some help. I am running a code that takes commands from
Marsyas(open source for Music analysis).

#!/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
#!/bin/bashimport math
import re
import numpy
import string
import os.path
import sys
import commands



l =
"/Users/bmorab/Audio_Projecto/Data/Palco/PP3_44_distance_matrix/PP3_44_5.mf"

Col = open(l, 'r')
colist= []
songlist = []
for line in Col:
#print line
song = os.path.split(line)[1]
#print song
songlist.append(song)
colist.append(line)



cmd = "sfplay " + colist[2]
print cmd
fileout = commands.getoutput(cmd)
print fileout



It basically reads song files from the .mf file, stores them in a list
and play one of the songs from the list. It does work with some music
but mostly it gives an error like this:

sfplay
/Volumes/HAL/Datasets/Audio/PalcoPrincipal/mp3_resampled_44100/10005.mp3

sh: -c: line 1: syntax error near unexpected token `;'
sh: -c: line 1: `; } 2>&1'


Ive been searching for the meaning of the error, and It really depends
on the script, but I would conclude that I am missing a punctuation
mark??

Thank you very much for taking your time reading my request.

Looking forward to hearing from you.

Regards,
Bea
 
M

mmelchert

Hello to all!

I am struggling with a script in python for a while now, and decided
to look for some help. I am running a code that takes commands from
Marsyas(open source for Music analysis).

#!/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
#!/bin/bashimport math <<==
import re
import numpy

have a close look at the <<== line: I think you wanted it to read
import math rather than #!/bin/bashimport math?
 
D

Diez B. Roggisch

Hello to all!

I am struggling with a script in python for a while now, and decided
to look for some help. I am running a code that takes commands from
Marsyas(open source for Music analysis).

#!/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
#!/bin/bashimport math

This is bogus. Replace it with

#!/usr/bin/python

and put the "import math" on the next line.

Diez
 
P

Peter Otten

I am struggling with a script in python for a while now, and decided
to look for some help. I am running a code that takes commands from
Marsyas(open source for Music analysis).
cmd = "sfplay " + colist[2]
print cmd
fileout = commands.getoutput(cmd)

You have to ensure here that characters that have a special meaning for the
shell are escaped correctly. The best approach is probably to use subprocess
instead of commands:

fileoutput = subprocess.Popen(["sfplay", colist[2]],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).communicate()[0]

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top