|
Home > Archive > Unix Shell > December 2006 > How to use fuser?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Bo Yang 2006-12-02, 7:30 am |
| I have look over the fuser manual, and I do following:
#vi recover
#fuser -n file recover
But the fuser command give nothing while the manual
said this command will output the pid of the vi command.
So, is this a bug or am I wrong to using the command as
above?
| |
| Stephane CHAZELAS 2006-12-02, 1:16 pm |
| 2006-12-02, 20:52(+08), Bo Yang:
> I have look over the fuser manual, and I do following:
>
> #vi recover
> #fuser -n file recover
>
> But the fuser command give nothing while the manual
> said this command will output the pid of the vi command.
>
> So, is this a bug or am I wrong to using the command as
> above?
vi only has the "recover" file open when it reads its content
upon startup and when it writes the new content upon :w. Some vi
implementations will not read the full content in memory, so may
keep the file open, or may use mmap, it's up to the
implentation, you can't really rely on it.
(what's -n, by the way for your fuser?).
--
Stéphane
| |
| loic-dev@gmx.net 2006-12-02, 7:21 pm |
| Hello,
> I have look over the fuser manual, and I do following:
>
> #vi recover
> #fuser -n file recover
>
> But the fuser command give nothing while the manual
> said this command will output the pid of the vi command.
>
> So, is this a bug or am I wrong to using the command as
> above?
You don't know when vi will effectively have the 'recover' file opened.
You should rather test as follows:
# cat > foo &
# fuser -n file foo
foo: 2060
# ps -eo comm,pid | grep 2060
cat 2060
Cheers,
Loic.
| |
| Bo Yang 2006-12-03, 1:28 am |
| loic-dev@gmx.net :
> Hello,
>
>
> You don't know when vi will effectively have the 'recover' file opened.
> You should rather test as follows:
>
> # cat > foo &
> # fuser -n file foo
> foo: 2060
> # ps -eo comm,pid | grep 2060
> cat 2060
>
> Cheers,
> Loic.
Thank you Loic. I understand it, vi will not have the file, if I
only open it but with no writing.
But, for a network connection, I have some problem too.
#ssh server ping anthoerserver
#netstat //I found the ssh port
#fuser -n tcp -4 port
But the command again give me nothing!
Why?
This time I use the net connection!
| |
| loic-dev@gmx.net 2006-12-03, 7:20 pm |
| Hello Bo,
> Thank you Loic. I understand it, vi will not have the file, if I
> only open it but with no writing.
>
> But, for a network connection, I have some problem too.
>
> #ssh server ping anthoerserver
> #netstat //I found the ssh port
> #fuser -n tcp -4 port
>
> But the command again give me nothing!
> Why?
> This time I use the net connection!
Perhaps sshd uses IPv6 by default (well likely, IPv4 mapped IPv6). Try:
# fuser -n tcp -6 ssh
A simpler command consists to search for both IPv4/6 as follows:
# fuser ssh/tcp
Cheers,
Loic.
| |
| Bo Yang 2006-12-04, 1:33 am |
| loic-dev@gmx.net :
> Hello Bo,
>
>
> Perhaps sshd uses IPv6 by default (well likely, IPv4 mapped IPv6). Try:
> # fuser -n tcp -6 ssh
>
> A simpler command consists to search for both IPv4/6 as follows:
> # fuser ssh/tcp
>
> Cheers,
> Loic.
>
No, all of these give me nothing.
Is something wrong with my machine.
Or need I enable some kernel feather to make use of this utility?
| |
| loic-dev@gmx.net 2006-12-04, 7:20 am |
| Hello Bo,
> No, all of these give me nothing.
> Is something wrong with my machine.
> Or need I enable some kernel feather to make use of this utility?
On which OS are you working?
You should perhaps address your problem on a dedicated newsgroup for
your OS, as comp.unix.shell mainly deal which shell programming
problems under Unix.
HTH,
Loic.
| |
| Bo Yang 2006-12-04, 7:20 am |
| loic-dev@gmx.net :
> Hello Bo,
>
>
> On which OS are you working?
>
> You should perhaps address your problem on a dedicated newsgroup for
> your OS, as comp.unix.shell mainly deal which shell programming
> problems under Unix.
I think there may be something wrong with my
environment. I just use lsof instead for the
same purpose. Thanks anyway!
Thanks!
|
|
|
|
|