the return value of a process

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
Rakesh UV [ Fr, 21 Dezember 2007 09:07 ] [ ID #1891895 ]

Re: the return value of a process

"rakesh uv" <uvrakesh [at] gmail.com> schrieb im Newsbeitrag
news:74fa2b10-9b33-4493-9352-72608f866351 [at] x29g2000prg.google groups.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
Joachim Schmitz [ Fr, 21 Dezember 2007 09:45 ] [ ID #1891896 ]

Re: the return value of a process

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
Stephane CHAZELAS [ Fr, 21 Dezember 2007 10:45 ] [ ID #1891900 ]

Re: the return value of a process

On Dec 21, 2:45 pm, Stephane Chazelas <stephane_chaze... [at] yahoo.fr>
wrote:
> 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

Thanks stephane
Rakesh UV [ Fr, 21 Dezember 2007 11:47 ] [ ID #1891904 ]
Linux » comp.unix.shell » the return value of a process

Vorheriges Thema: Re: Problem with memory (unix) allocation to JVM running Java program
Nächstes Thema: Hex to decimal replacement