section | x-masysma-name | title | date | lang | author | keywords | x-masysma-version | x-masysma-repository | x-masysma-website | x-masysma-owned | x-masysma-copyright | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32 |
java-nostalgic-tools |
Nostalgic Java Tools |
2020/10/14 22:41:12 |
en-US |
|
|
1.0.0 |
1 |
Copyright (c) 2020 Ma_Sys.ma.
For further info send an e-mail to Ma_Sys.ma@web.de.
|
Package mdvl-java-nostalgic-tools
provides a few Ma_Sys.ma Tools that are
included in MDVL for nostalgia only, because their functionality is provided
by other, and well-maintaned tools. Still, the tools are very simple and run
on Windows as well as Linux which does not always hold for their better
counterparts.
Compile all tools (requres Ant and a JDK) by running
$ ant
Package them together (on Debian systems with suitable depnendencies installed) by running
$ ant package
The following sections describe the individual tools in man-page style.
cmdcolors
-- Display color capabilities of the console (max 16 colors)
cmdcolors
Outputs a table with certain useful ANSI escape sequence colors. Does not display all possible combinations but some that are considered most useful.
colortest-16b(1) -- does the same thing but better in all regards: The output is less convoluted and it reminds the user of the correct escape sequence syntax.
netread
-- Listen to data incoming on sockets and display it in hex.
netread [port]
Listens on the specified port by using a socket. Whenever data comes in, it prints them out in HEX. Once the connection closes, a new socket is created.
The default port is 5971 unless otherwise specified.
Open a terminal and run netread:
$ netread
NetRead 1.0, Copyright (c) 2012 Ma_Sys.ma.
For further info send an e-mail to Ma_Sys.ma@web.de.
Listening on port 5971
Press enter to terminate application.
68 65 6c 6c 6f 20 77 6f 72 6c 64 0a hello.world.
6e 65 77 20 77 6f 72 6c 64 0a new.world.
In another terminal, send some messages:
$ echo hello world | nc 127.0.0.1 597
$ echo new world | nc 127.0.0.1 5971
nc(1), xxd(1) and the shell together do the same:
$ while true; do nc -l 5971 | xxd; echo; done
00000000: 6865 6c6c 6f20 776f 726c 640a hello world.
00000000: 6e65 7720 776f 726c 640a new world.
version_change
-- Compute checksums of a directory's files to detect changes.
version_change display DATABASE DIR
version_change accept DATABASE DIR
This tool recursively computes the SHA-256 checksums of all files found
below directory DIR
and stores them in a CSV file DATABASE
when invoked with
accept
.
When invoked with display
, it will compute all the checksums and based on
that, output a list of files that were either added, changed or removed.
version_change
not usejava.nio
API for traversal and is thus prone to endless loops in the presence of symlinks, mount points etc.- After displaying the changes, accepting them takes another complete run that needs to compute all the checksums. This is highly inefficient!
find(1), sort(1), diff(1), sha256sum(1)
Combine them as follows:
# accept
find . -type f -exec sha256sum {} + | sort > state_old.txt
# display
find . -type f -exec sha256sum {} + | sort > state_new.txt
diff state_old.txt state_new.txt
# accept (without recomputation!)
mv -f state_new.txt state_old.txt
If cut
and paste
are added to swap the columns in the state_
files, it
behaves even more like version_chnage
in that it will become possible to
detect the difference between changed and added/deleted files.
vcp
-- Copy directory trees while displaying a lot of progress info
vcp SRC DST
Copies directory SRC
to DST
. Two modes of invocation are to be
distinguished:
- If
SRC
ends on a trailing slash (e.g./root/
), then its contents are put directly belowDST
. - If
SRC
does not end on a trailing slash (e.g./root
), then a directory with the same name asSRC
is created belowDST
and data is copied like withcp -R SRC DST
.
During Invocation, vcp
displays a lot of progress information. Some of the
ideas (speed diagram) have been taken up by Windows 10's copy function while
others (progress bars separate for number of files and data) are quite
uncommon.
Visual Copy does not retain any file attributes nor modification times.
1 failed to list some directories or incorrect commandline options 2 failed to copy some files 64 Bug
rsync(1) -- does everything better except for the progress bars.
# Command to replace
vcp /root/ /tmp/test
# Very reliable, works efficiently over netcat to transfer large
# structures. No resumption upon interruption.
tar -C /root -c . | pv | tar -C /tmp/test -x
# Slightly slower (?) than tar, but allows resuming the transfer
# and displays the names of the files as transferred
rsync -av /root/ /tmp/test/
xmlparser
-- Commandline tool to parse XML files with Java
xmlparser FILE
This program attempts to parse the given XML file using a SAXParser
that is
validating and XInclude aware. In case of invalid files, the exception is
printed to console, otherwise no output is shown.
xmlstarlet(1)
which can provide a similar use with xmlstarlet validate
.