FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 04-15-2012, 06:47 PM
Sthu Deus
 
Default Fetching path from ps-or-proc.

Good time of the day.


Please help me to fix my problem. I will start w/ its description.

I need to fetch a file path. I can do so by:

. ps -AHf | grep [...] (as it is visible from command parameters)

. cat /proc/n/cmdline (same command arguments)

Problem is that as the path contains UTF-8 char.s for unknown to me
reason one char. in the whole path is represented w/ '?' char. - in
case I fetch the path using 'ps' command. Whereas fetching it
from /proc - I get the path in int purity.

My questions are:

. why only one char. is represented w/ '?' - and not all of them?

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

That's it.

Thanks for Your time and answer.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4f8b17b4.c695700a.79fb.ffffbf5e@mx.google.com">htt p://lists.debian.org/4f8b17b4.c695700a.79fb.ffffbf5e@mx.google.com
 
Old 04-16-2012, 09:08 PM
Camalen
 
Default 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/aUp.txt

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jmi1o7$o2a$12@dough.gmane.org">http://lists.debian.org/jmi1o7$o2a$12@dough.gmane.org
 

Thread Tools




All times are GMT. The time now is 12:13 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org