in reply to Re: Parsing /etc/remote
in thread Parsing /etc/remote

Thanks merlyn, it seems to almost work.
use strict; use warnings; use English; use Term::Cap; my $PortName = 'MyPort'; if (scalar(@ARGV)) { $PortName = $ARGV[0]; } $ENV{TERMPATH} = '/etc/remote'; my $terminal = Tgetent Term::Cap { TERM => $PortName, OSPEED => 9600}; print $terminal->Tgoto('dv', "", "",);

So, when called with MyPort parameter, it gives me /dev/term/b as expected. However, when called with MyAlias parameter, it does not return anything (but no errors either). What am I missing?

Replies are listed 'Best First'.
Re^3: Parsing /etc/remote
by serf (Chaplain) on Nov 29, 2005 at 15:49 UTC
    Although it doesn't seem to be required by the file format in the examples and man pages I've looked at, if the end of the alias line is terminated with a colon it will work as expected.
      Unfortunately, the customers' /etc/remote will be as I have outlined above - without a colon. However, after reading the documentation, it seems that I should be able to set the TERMCAP environment variable to account for that, but I cannot seem to figure out how (Correction - to what. Any suggestions?
        $ENV{TERMCAP} = "something"; sets the the TERMCAP environment variable, but I'm guessing you're asking *what* to set it to.

        Update:

        Nasty kludge?

        use strict; use warnings; use Term::Cap; my $PortName = 'MyPort'; if (scalar(@ARGV)) { $PortName = $ARGV[0]; } my $remote = "/etc/remote"; my $tmp_rem = "/tmp/remote.$$"; open (REMOTE, $remote) || die "Can't read '$remote': $!\n"; open (TMPREM, "> $tmp_rem") || die "Can't write to: '$tmp_rem': $!\n"; while(<REMOTE>) { s/$/:/ if /tc=[^:]+$/; print TMPREM; } close(TMPREM); close(REMOTE); $ENV{TERMPATH} = $tmp_rem; my $terminal = Tgetent Term::Cap { TERM => $PortName, OSPEED => 9600}; print $terminal->Tgoto('dv', "", "",), $/; unlink($tmp_rem);