I want to run a certain Python script that calls MATLAB through the Ubuntu 12.04 command terminal. The script has this line:
os.system("matlab -nojvm -nodisplay -nosplash -r "ReadFates5mm;quit"")
but it returns a syntax error on the last portion with ReadFates.. and I don't know how to fix it.
I know there's a way using the matlab python bridge but I would have to convert my matlab file into a function.
Thanks!
os.system('matlab -nojvm -nodisplay -nosplash -r "ReadFates5mm;quit"')? OR escape the quotes properly."and'. The problem is that, to include a literal"inside a string delimited with"you should escape it with a backslash. E.g."Say \"something\"". The same is true for':'Say \'something\''. To avoid using the backslash you can use a different delimiter(e.g. if the string include"you use'as delimiter, and if the string contains'you use"). By the way:os.systemshouldn't be used. Replace it withsubprocess.call."&'in some scripting languages.'something'is string literal in many of the languages. Any escape character within singly quoted string is taken as literally. Also'$variable'will not be expanded in bash. etc. I am not very sure about usage of'vs"in python. I just wanted to tell OP, that "absolutely no difference between"and'" is not a generic statement.