Skip to content

Instantly share code, notes, and snippets.

@hfs
Created February 23, 2014 20:35
Show Gist options
  • Save hfs/9176883 to your computer and use it in GitHub Desktop.
Save hfs/9176883 to your computer and use it in GitHub Desktop.
Script to wrap one bulletin in a minimal WMO message structure
#!/usr/bin/perl -wp
#
# Script to wrap one bulletin in a minimal WMO message structure
#
# Usage:
# bulletinize-file infile > outfile
# or
# bulletinize-file < infile > outfile
BEGIN {
print "\x01\x0D\x0D\n";
}
s/\x0D?\n/\x0D\x0D\n/;
END {
print "\x0D\x0D\n\x03";
}
@engshara
Copy link

how can i run this script in windows
and how can select specefic folder that contain the data by the script.
can you plz explain each line in the script?

@engshara
Copy link

plz tell me how can i run this script on windows operating system, the data for example are in this path :C:\Users\Owner\Documents\eng sharaf

@hfs
Copy link
Author

hfs commented Aug 20, 2022

Hi @engshara,
you can get Perl for Windows here: https://www.perl.org/get.html . If you don’t want to install Perl just for this purpose, the same script could also be written in other programming languages easily.

Download the script as bulletinize-file.pl and save it somewhere. Then you can run it as perl bulletinize-file.pl < inputfile > outputfile. Replace inputfile and outputfile with the actual file names. These can also be absolute paths. This way you can select the specific folder.

Line 9-11 outputs the bytes 01 0D 0D 0A before the content of the input file.

Line 12 loops over every line in the input file. It copies the line into the output, but it replaces the end of line consisting of optionally 0D and 0A with 0D 0D 0A.

Line 13-15 outputs the bytes 0D 0D 0A 03 after the input file’s contents.

@engshara
Copy link

engshara commented Aug 21, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment