[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fetching path from ps-or-proc.



On Mon, 16 Apr 2012 01:47:12 +0700, Sthu Deus wrote:

(...)

> My questions are:
> 
> . why only one char. is represented w/ '?' - and not all of them?

It can be a single accented "á" (or another special character) which fails
to render properly.

> . I use utf-8 env. how I can fetch the path using 'ps' command?

Let's try it:

sm01@stt008:~$ ls -la Desktop/ | grep á
drwxr-xr-x  2 sm01 sm01     80 abr 16 19:18 áéñp


sm01@stt008:~$ gedit Desktop/á*/*.txt


sm01@stt008:~$ ps -AHf | grep á
sm01      9505  9463  0 22:02 pts/0    00:00:00       grep á


sm01@stt008:~$ ps -AHf | grep gedit
sm01      9484  9463  0 21:59 pts/0    00:00:00       grep gedit
sm01      9478     1  5 21:59 ?        00:00:01   gedit file:///home/sm01/Desktop/%C3%A1%C3%A9%C3%B1p/%C3%A1%C3%B1aU%C2%A8p.txt

Mmmm... It looks like a bunch of hexadecimal utf-8 gibberish :-)

By Googling around I've found this page which explains how to get an URL 
decoder/encoder from bash:

http://spielwiese.la-evento.com/xelasblog/archives/23-URL-decode-und-encode-in-der-Bash.html

(nope, I cant read German but code is self-explanatory :-P)

So, if we apply it to this, seems to do a reasonably good work:

sm01@stt008:~$ ps -AHf | grep gedit | tail -1 | echo -e $(sed 's/%/\\x/g')
sm01 9510 1 0 22:04 ? 00:00:02 gedit file:///home/sm01/Desktop/áéñp/áñaU¨p.txt

Greetings,

-- 
Camaleón


Reply to: