in reply to null byte issue in system command

system("echo -e "\xFF\x08\x01" >> /dev/ttyACM0");

Why do you shell out just to write to a file or device? Perl has open, print, close, no need to mess with the shell. Using File::Slurp reduces that to a single line for each write, including error handling:

use File::Slurp qw( append_file ); if ($foo) { append_file('/dev/ttyACM0',{ err_mode => 'croak', binmode => ':raw +' },"\xFF\x08\x00"); } else { append_file('/dev/ttyACM0',{ err_mode => 'croak', binmode => ':raw +' },"\xFF\x08\x01"); }

Some other notes:

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: null byte issue in system command (Path::Tiny append_raw)
by Anonymous Monk on Apr 01, 2015 at 09:34 UTC