I have got a utility "sock" which is C executable (under linux) on my machine. It acts like a server or client based on the arguments passed at the command line. I want to run it through a python script.
I am using the subprocess call function to execute the C executable.
I am making the call as follows:

import subprocess as sp
sp.call("python "+str, shell = True)
where str = "/root/sock_dir/sock-0.3.2/src/sock"

But the python script is not compiling and it is giving the following error:

str =  /root/sock_dir/sock-0.3.2/src/sock -u -s 5555
  File "/root/sock_dir/sock-0.3.2/src/sock", line 1

SyntaxError: Non-ASCII character '\xb1' in file /root/sock_dir/sock-0.3.2/src/sock on line 2, but no encoding declared; see details here

Could any one please tell me how to run this C utility in Python?


Non-ASCII char '\xb1' is a ±

You may need to add
# -*- coding: iso-8859-15 -*-
# -*- coding: <utf-8> -*-
as the first line in your Python code

This question has already been answered. Start a new discussion instead.