|
Home > Archive > Unix Shell > December 2007 > the return value of a process
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]
| Author |
the return value of a process
|
|
| rakesh uv 2007-12-21, 7:33 am |
| hi,
is there any way to find the exact meaning of message given
by a Unix command
for example
mv: cannot access hello.c
similarly is there any way to find the meaning of the
error number or message displayed
by compilers
Rakesh UV
| |
| Joachim Schmitz 2007-12-21, 7:33 am |
| "rakesh uv" <uvrakesh@gmail.com> schrieb im Newsbeitrag
news:74fa2b10-9b33-4493-9352-72608f866351@x29g2000prg.googlegroups.com...
> hi,
> is there any way to find the exact meaning of message given
> by a Unix command
> for example
> mv: cannot access hello.c
>
> similarly is there any way to find the meaning of the
> error number or message displayed
> by compilers
These should be in the documentation for the command in question.
If not: bad luck, you'd need to look at the source code instead.
Bye, Jojo
| |
| Stephane Chazelas 2007-12-21, 7:33 am |
| On Fri, 21 Dec 2007 00:07:58 -0800 (PST), rakesh uv wrote:
> hi,
> is there any way to find the exact meaning of message given
> by a Unix command
> for example
> mv: cannot access hello.c
[...]
Often error messages are converted from the error code returned
by a system call made by the command. It is not the case above
as the "standard error message" wouldn't have anything specific
like "hello.c" in it, but if the error message is not self
explanatory and if the documentation for you command is not
specific enough about the error messages, then you can sometimes
reverse engineer to understand what happens.
For instance, if you see:
$ ls /etc/motd/bar
/bin/ls: /etc/motd/bar: Not a directory
You can search what "Not a directory" is the message for. For
instance, if your shell is zsh, you can do:
$ zmodload zsh/system
$ {for e ($errnos) syserror -p$e: $e} |& grep -i 'not a dir'
ENOTDIR:Not a directory
That means that ls made a system call that returned with the
ENOTDIR error.
Now, if you think of what ls does, it retrieves file attributes,
so it must be doing a stat(2) system call.
Now, the stat(2) man page tels us:
ENOTDIR
A component of the path is not a directory.
That's a more useful message.
On Linux, you could do:
~$ strace -f ls /etc/motd/foo |& grep -i 'not a dir'
stat64("/etc/motd/foo", 0x805cd24) = -1 ENOTDIR (Not a directory)
write(2, ": Not a directory", 17: Not a directory) = 17
(the |& syntax is zsh/csh/tcsh specific)
That's a shorter way to now which error (ENOTDIR) to lookup in
which man page (stat64).
~$ man stat64 | sed '/ENOTDIR/,/^$/!d'
ENOTDIR
A component of the path is not a directory.
(other systems have commands equivalent to Linux' strace (truss,
tusc...)).
For compiler errors, look at the documentation for your compiler.
--
Stephane
| |
| rakesh uv 2007-12-21, 7:33 am |
| On Dec 21, 2:45 pm, Stephane Chazelas <stephane_chaze...@yahoo.fr>
wrote:
> On Fri, 21 Dec 2007 00:07:58 -0800 (PST), rakesh uv wrote:
>
> [...]
>
> Often error messages are converted from the error code returned
> by a system call made by the command. It is not the case above
> as the "standard error message" wouldn't have anything specific
> like "hello.c" in it, but if the error message is not self
> explanatory and if the documentation for you command is not
> specific enough about the error messages, then you can sometimes
> reverse engineer to understand what happens.
>
> For instance, if you see:
>
> $ ls /etc/motd/bar
> /bin/ls: /etc/motd/bar: Not a directory
>
> You can search what "Not a directory" is the message for. For
> instance, if your shell is zsh, you can do:
>
> $ zmodload zsh/system
> $ {for e ($errnos) syserror -p$e: $e} |& grep -i 'not a dir'
> ENOTDIR:Not a directory
>
> That means that ls made a system call that returned with the
> ENOTDIR error.
>
> Now, if you think of what ls does, it retrieves file attributes,
> so it must be doing a stat(2) system call.
>
> Now, the stat(2) man page tels us:
> ENOTDIR
> A component of the path is not a directory.
>
> That's a more useful message.
>
> On Linux, you could do:
>
> ~$ strace -f ls /etc/motd/foo |& grep -i 'not a dir'
> stat64("/etc/motd/foo", 0x805cd24) = -1 ENOTDIR (Not a directory)
> write(2, ": Not a directory", 17: Not a directory) = 17
>
> (the |& syntax is zsh/csh/tcsh specific)
>
> That's a shorter way to now which error (ENOTDIR) to lookup in
> which man page (stat64).
>
> ~$ man stat64 | sed '/ENOTDIR/,/^$/!d'
> ENOTDIR
> A component of the path is not a directory.
>
> (other systems have commands equivalent to Linux' strace (truss,
> tusc...)).
>
> For compiler errors, look at the documentation for your compiler.
>
> --
> Stephane
Thanks stephane
|
|
|
|
|