>/dev/msglog 2<>/dev/msglog </dev/console

>/dev/msglog 2<>/dev/msglog </dev/console

Post by Michael Wa » Sat, 11 Jan 2003 07:07:04





Quote:

>http://groups.google.com/groups?as_umsgid=at5pt6%24nuu%242%40reader1....

>Why I don't mind people being pointed to google, it's rather
>pointless to do it in the newsgroup over and over again and not
>in private mail.

Very true. The reason the link is posted instead of answers is because
the link does not contain answers. It is a copy of man page which is
easily avaible.

Another drawback with the link is, when real expert sees the link,
they think the question is answered, and pass the post.

I am interested to see the answers:

(1) In what situation "<>" is used? Examples?
(2) Will read change the position for write, and vice versa?
(3) Can read/write be reposition? seek()? but in Shell?
(4) Is "<>" supposed to be used for C-like programs?
(5) What is the use of "<>" in shell?
(6) Suppose myprog.ksh looks like:
read -u2 i
print -u2 $i
read -u2 i
print -u2 $i
read -u2 i
print -u2 $i
And I run "myprog.ksh 2<> myfile"
and myfile looks like
a
1
b
2
c
3
what myfile will look like after run and why?
(7) what is /dev/msglog, how it is configured and where it goes?
(8) It looks from the inittab lines that every rc scripts are logged,
but I do not see it happen. What do I do to make every start/stop
script gets logged?

Thanks a lot. (I removed many irrelevent groups, and cross post it to
comp.unix.shell).

 
 
 

>/dev/msglog 2<>/dev/msglog </dev/console

Post by Sven Maschec » Wed, 15 Jan 2003 00:43:01


[fup2 to c.u.shell]


> (1) In what situation "<>" is used? Examples?

In this case, the _older_ variant of the SUS is more informative:

<http://www.unix-systems.org/single_unix_specification_v2/xcu/chap2.html>

| The <> operator could be useful in writing an application that
| worked with several terminals, and occasionally wanted to start up a
| shell. That shell would in turn be unable to run applications that
| run from an ordinary controlling terminal unless it could make use of
| <> redirection. The specific example is a historical version of the
| pager more, which reads from standard error to get its commands, so
| standard input and standard output are both available for their usual
| usage. There is no way of saying the following in the shell without <>:
|
|       cat food | more - >/dev/tty03 2<>/dev/tty03

BTW: In fact even the original Bourne shell "always" accepted <>,
but it was buggy by omitting O_RDWR when open()ing.  Due to the rare
usage, <> was never fixed nor documented by AT&T.

It was (AFAIK: only) fixed with SunOS 5.6 -- probably even for the
previously mentioned inittab entries.

Quote:> (2) Will read change the position for write, and vice versa?

Certainly: you would need separate entries in the "open file table"
for separate positioning; one filedescriptor can only point to one
entry, though.

Instead your question better applies to something like:
"exec 3>file; exec 4>&3" vs "exec 3>file; exec 4>file"

Quote:> (3) Can read/write be reposition? seek()? but in Shell?

I don't know of any shell offering a "seek" functionality to the user.
(But in principle, the shell certainly could do that.)

You could open the file several times (like in the above) and "save"
a file pointer for later use.  (doesn't look extremely useful, though.)

$ exec 3>file; exec 4>file
$ echo AB 1>&3; echo CD 1>&3
$ echo 'x\c' 1>&4;  cat file
xB
CD

Quote:> (4) Is "<>" supposed to be used for C-like programs?

This is an ambiguous question.

Quote:> (5) What is the use of "<>" in shell?

see (4) and (1)?

Quote:> (6) Suppose myprog.ksh looks like:
> read -u2 i
> print -u2 $i
> [...] And I run "myprog.ksh 2<> myfile"

But the shell already writes its prompt and diagnostics to STDERR.
Did you have this collision in mind or "exec 3<>file" instead?

The flag "-u" in ksh88 seems to be implemented by handling even more,
internal, file descriptors, which yields "unexpected" results in this
concern.  And at least ksh88i-M on SunOS 5.7 even looks buggy here.

Oh, and ksh93 (apparently since the 2nd release of version "n-") keeps
file descriptor 3 to the the shell history file but fails to reopen
it with a higher FD, if you want to use FD 3.

Thus, did you actually have the following in mind?

exec 4<>myfile
read  i 0<&4
echo $i 1>&4
[...]

Quote:> (7) what is /dev/msglog, how it is configured and where it goes?

Haven't you read msglog(7D) and sysmsg(7D) yet?
It ends up in /dev/console; see also xconsole(1) ;-)

Quote:> (8) [...] What do I do to make every start/stop script gets logged?

Adjust inittab.

Sven

 
 
 

1. >/dev/msglog 2<>/dev/msglog </dev/console

In inittab, some entry is entitled with ">/dev/msglog 2<>/dev/msglog
</dev/console",  what is that used for? Why need it followed by the
standard entry?

Such as
Example--Default inittab File
The following example shows an annotated default inittab file:
 1 ap::sysinit:/sbin/autopush -f /etc/iu.ap
 2 ap::sysinit:/sbin/soconfig -f /etc/sock2path
 3 fs::sysinit:/sbin/rcS sysinit   >/dev/msglog 2<>/dev/msglog
</dev/console
 4 is:3:initdefault:
 5 p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog
2<>/dev/...
 6 sS:s:wait:/sbin/rcS              >/dev/msglog 2<>/dev/msglog
</dev/console
 7 s0:0:wait:/sbin/rc0              >/dev/msglog 2<>/dev/msglog
</dev/console
 8 s1:1:respawn:/sbin/rc1           >/dev/msglog 2<>/dev/msglog
</dev/console
 9 s2:23:wait:/sbin/rc2             >/dev/msglog 2<>/dev/msglog
</dev/console
 10 s3:3:wait:/sbin/rc3             >/dev/msglog 2<>/dev/msglog
</dev/console
 11 s5:5:wait:/sbin/rc5             >/dev/msglog 2<>/dev/msglog
</dev/console
 12 s6:6:wait:/sbin/rc6             >/dev/msglog 2<>/dev/msglog
</dev/console
 13 fw:0:wait:/sbin/uadmin 2 0      >/dev/msglog 2<>/dev/msglog
</dev/console
 14 of:5:wait:/sbin/uadmin 2 6      >/dev/msglog 2<>/dev/msglog
</dev/console
 15 rb:6:wait:/sbin/uadmin 2 1      >/dev/msglog 2<>/dev/msglog
</dev/console
 16 sc:234:respawn:/usr/lib/saf/sac -t 300
 17 co:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` console
login: "
    -T terminal-type -d /dev/console -l console -m ldterm,ttcompat  

in
http://docs.sun.com/db/doc/805-7228/6j6q7uepg?a=view

2. scsi disk problem or kernel wierdness

3. How to read "/sbin/rcS >/dev/msglog 2<>/dev/msglog </dev/console" ?

4. Urgent! I buy 7043-140 Motherboard

5. what is the commands means: 2<>/dev/msglogs

6. DirectoryIndex named after directory??

7. <><><> MOUNTING EXTENDED PARTITION <><><>

8. Wavelan card not talking

9. Wanted: <><><> Unix Specialist <><><>

10. LILO help <><><><><><>

11. <Alt>+<key> = <Esc><key> ?

12. *{<><>}*Linux*Screen*Difficulties*{<><>}*

13. << <<anyone using dyn-html?>> >>