# redirection in virtual console



## globsd (May 7, 2010)

I'm looking for the state-of-art to continuously display live log in a virtual terminal.

After boot, I want to have the normal login terminal on ttyv0, and display logs on ttyv1

A redirection works (launch by cron), but I like to replace the getty login with a custom command like 'tail -f /var/log/...' or 'iftop ...'

I try to modify /dev/ttys, but I don't think it's the right way.


Thanks for help...


----------



## SirDice (May 7, 2010)

globsd said:
			
		

> I'm looking for the state-of-art to continuously display live log in a virtual terminal.


sysutils/screen + misc/mtail


----------



## globsd (May 10, 2010)

Thanks,

I take a look to screen, and it's fine when I try to launch it from shell.
When I try to launch it by an rc.d script, it failed because screen don't know the console.

here is the command to display :

```
#!/bin/sh
# /root/test : survey script to display on ttyv0 at boot
/usr/local/bin/screen -t test top
```

here is the rc.d script :

```
#!/bin/sh
# launch the survey script at boot
. /etc/rc.subr
name="test"
rcvar=`set_rcvar`
command="/root/test"
load_rc_config $name
test enable=${test_enable-"NO"}
test_pidfile=${test_pidfile-"/var/run/test.pid"}
pidfile="${test_pidfile}"
run_rc_command "$1"
```

I put test_enable="YES" in /etc/rc.conf, but there is an error at boot :

```
...
Starting test.
Please set a terminal type.
/etc/rc: WARNING: failed to start test
...
```


----------



## SirDice (May 10, 2010)

You don't need to launch it via rc. Just start it and when you're done disconnect (ctrl-A, D). The processes started inside screen will keep running.


----------



## globsd (May 10, 2010)

Thanks for your help.

just doing :

```
#screen -t test top
C-a d
#exit
or C-a D D
```

the session is still running after the session is close, but what I want is to display the session even if all the sessions are closed... (or before any opening session).


----------



## SirDice (May 10, 2010)

[cmd=]screen -r[/cmd] to get back to it.


----------

