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

Recommended Answers

All 2 Replies

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

Hi thanks for the reply. Now I am able to run the script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.