Re: ASCII to binary and /proc

From: Andrew Taylor (ataylor_at_its.to)
Date: 09/30/04


Date: Thu, 30 Sep 2004 17:10:48 GMT

Joseph wrote:

> I was doing a assignment ,and I do not know if there is any lib or function
> which could convert a ACSII char to binary number and vice versa.

In C, use atoi, strtol or sscanf. In shell scripts, strings are
interpreted as numbers by expr or let.

> and there is another question,is there any way to get the other process's
> executable (filename)by only accessing the /proc dir ? like process1 access
> the /proc and there's a dir with name 1394 (/proc/1394) ,how can I get the
> filename of process PID 1394?(say,emacs ,here for example)

Look for /proc/1394/exe. It will be a symbolic link to the executable.
  You can get the real filename by calling readlink from C or running
the readlink program from the shell.

-- 
Andrew