-
-
Save aziob/e34cf64af7fad184265b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/lib64/riak/erts-5.8.4/bin/escript | |
%% -*- erlang -*- | |
%%! -smp enable -sname convert_binary_ring -mnesia debug verbose | |
main([RingFile, OutFile]) -> | |
try | |
{ok, Binary} = file:read_file(RingFile), | |
Ring = binary_to_term(Binary), | |
try | |
file:write_file(OutFile, io_lib:format("~p.~n", [Ring])), | |
io:format("Saved ~p to ~p.~n", [RingFile, OutFile]) | |
catch | |
A:B -> | |
io:format("Exception ~p:~p~n",[A,B]) | |
end | |
catch | |
_:_ -> | |
usage() | |
end; | |
main([RingFile]) -> | |
main([RingFile, lists:append(RingFile,".txt")]); | |
main(_) -> | |
usage(). | |
usage() -> | |
io:format("usage: convert_binary_ring RingFile [OutputFile]\n"), | |
halt(1). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment