in reply to Re^2: How to set tty settings from perl
in thread How to set tty settings from perl

Unfortunately it seems that the OS in question (ubuntu) lacks packages for IO::Termios.

Yes, IO::Termios needs to be installed from CPAN, using e.g. cpanm, although installing modules into the system Perl has the caveats that uninstallation is tricky and it may clash with modules installed using the system's package manager. You could consider local::lib or even perlbrew, and it's also possible to install modules to some other global directory where they won't clash with modules installed by the system package manager (depending on the distro, that could be something like perhaps /usr/local/lib/site_perl, check your perl -V output for the preconfigured @INC).

But it definitely didn't die while setting 19200, which it now does.

Yes, that is indeed strange. Can you say what the old and new versions of IO::Stty and Perl were?

Lastly, I looked at your link about system -- maybe I'm missing something, but system(LIST) seems to be just fine?

Well, on a *NIX system the system(LIST) form should be "safe". Using a module gives you the advantage of built-in error handling (e.g. IPC::System::Simple, which has a drop-in replacement for system), or the ability to capture STDOUT/ERR in case you want to hide it from the user or inspect it for error messages (e.g. IPC::Run3). If you don't care about those things, then yes, system(LIST) where LIST has two or more elements is fine.

(BTW, an open mode of +> will clobber the file first - for a serial port it's probably fine, but for regular files you would probably want +< for read-write access instead.)

Replies are listed 'Best First'.
Re^4: How to set tty settings from perl
by Sec (Monk) on Dec 18, 2019 at 00:04 UTC
    Yea, I don't really want to install perl modules manually. But thanks for the suggestions there, will keep them in mind for the future.

    I think rt://97576 has analyzed the problem of die()ing, it's just that the changes never got picked up.

    Point taken on the open() mode. Even though it's probably not relevant, +< seems more logical. Will change that :)

    Thanks.