0

Hi,

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)
[icode]
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?

Regards,
Prashanth

Edited by Reverend Jim: Fixed formatting

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by prashanth s j
0

Non-ASCII char '\xb1' is a ±

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.