MiggyMan has asked for the wisdom of the Perl Monks concerning the following question:

As per the title, id like to, if possible replace a tty on a FreeBSD box with a perl script, basicly i need an application that starts when the system does, grabs input from stdin and does it's buisness on receiving text most of which i've done but i find myself in need ot help when it comes to getting the machine to accept input without loggin in and running the client script. I cant for the life of me figure out how you'd go about writing a tty replacment in perl.

Replies are listed 'Best First'.
Re: Replacing a Tty with a perl script
by etcshadow (Priest) on Apr 25, 2004 at 03:58 UTC
    Essentially, you just need to put your script in place of the getty (or variant). I'm not familiar enough with BSD to know if it is handled in exacly the same manner, but for a typical linux distro, you control this in your /etc/inittab file. I haven't monkeyed with it myself, but I think that you could get away with just changing:
    1:2345:respawn:/sbin/mingetty tty1
    to
    1:2345:respawn:/sbin/myscript.pl tty1
    Anyway, that's a good place to start trying.
    ------------ :Wq Not an editor command: Wq
      I did actualy try this but it it seems the os objects to having a tty replaced with anythinh but a properly written tty, or at least it objects to having something that doesnt behave the same way :)
        I take that back, editing the ttys file does work, but you have to set the type to unkown! Still using term::readkey in conjunction with that seems to herrald the best results.
Re: Replacing a Tty with a perl script
by matija (Priest) on Apr 25, 2004 at 05:51 UTC
    If you want to turn input echo on and off, you need to use a module such as Term::ReadKey. It's ReadKey method allows you to turn echo on and off (it can also read stuff immediately, without input buffering).

      This works like a charm, im not sure how I managed to miss it tbh as it was on the first page of the search results from cpan, ta muchly :) Moral of the story, dont search cpan at 3am :D