Convert from memcached output binary protocol to readable UTF8 in command line - memcached

Right now a lot of symbols are not readable via memcat/memccat or telnet (get) commands.
Is there anyway to convert the telnet/memcat/memccat output to UTF8 readable (except native clients)?
aim-server[~/www/next/src]$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get 20_dev_cache:c9bf76a9fa1e19ad92ab7195c64e47f8
VALUE 20_dev_cache:c9bf76a9fa1e19ad92ab7195c64e47f8 84 7914
�a:9:{s:14:"Licenses";a:2`�8:"QSL/TestModule"; 49:"JJJC-UNKK-MXZL-DAGW��� 42#20:"NNHJ2�6312-1 ";} R2��Tok �#�1#�#jC/TaxJar#E1:"�1
coreVersion#03#05:"majo`,3:"5.4#6#in� 8 B`build#
~35�� q#Wa ceKeyValue#$ �#!ad MURL#3 ehttps://xlocal/next/src/`'.php#(!jwav IN |1 L public_key#73 ssh-rsa A
ADAQAB CAQDWq4/EAVRilQslmKeA9A6y8f5i+oJSg0dfwaXUnbP6f4YwuJq8TOzr/q05HoQGS/biMExeu/YF2nu/Vo2RoBCV9rW5j+wPeIicgUQHarO+zoLTFM2+xdR7aG2MMEW4NO+4fdXgmRiqm9z6LJW4wpISZWiBqbJxsjaxeCvCVSsAtxlmP8Fg19lDB9OiMsll+GkMVAprH4xxhUiPz2hs2c6f9kf5kG2lf2lNS2bovobNFT2etds9so7HdbJ8GPVJf2wC0xUaRR7QNm0+HZ2SzfybYR11WQqmBrWVhZBVxhN343Knjh3jjW3jx/eOWWVeHezG8apD7YC58/ZVUhW3KdFbB3huUXNYmY8FWtYUkC+QEIjLkste57FvIMGb2Opwm4+inVf4hsVBs/a14bJgJGIn+7mLwvgsoAePunpRyv3tk0Wz+yM2KFy7xjHxt4wIIRUVRrp9D4ZHJbB9H7f0YcJRfCv/guIXywOJ1e1TDsjGfImbk77M+gV/gSHdnrlR2QRQYar7PcNWicVRKbDmbz9FERxhoSyd0Bhq+Jgp31oc2qxQ89#"6# 6:"auth�� KhgMQ+CBK9tAHrv00P4VIMj6tmBIENviEVAcMLbN+JbtnqXDrRpm RIbwxMurQeTqUAqgfva/nHoucBFAZETCX+LnsrIG2KvoVjP3XcZsrGQ== aim#example.comB�1#� installedAdC�224C�D)
�2#��G#�$A�� w��Y��0#)��i � �Ec��7:"enab �";b:0�;�/$C$�$�4#~utomatedShippingRefunds71LBS/SeentyOnePo#�
CDev/�`S3Imag�"� � �#+#Z

Related

Sh - how to remove all after selection

I'm trying to manipulate a string and the first step is to truncate the variable after a combination, so first I create the var:
SERVER_CONFIGURATION_FILE=$(curl some remove url)
And now my $SERVER_CONFIGURATION_FILE is something like that
client
dev tun
proto udp
remote 192.145.127.237 1194
resolv-retry infinite
remote-random
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ping 15
ping-restart 0
ping-timer-rem
reneg-sec 0
comp-lzo no
remote-cert-tls server
auth-user-pass
verb 3
pull
fast-io
cipher AES-256-CBC
auth SHA512
<ca>
-----BEGIN CERTIFICATE-----
MIIFCjCCAvKgAwIBAgIBATANBgkqhkiG9w0BAQ0FADA5MQswCQYDVQQGEwJQQTEQ
MA4GA1UEChMHTm9yZFZQTjEYMBYGA1UEAxMPTm9yZFZQTiBSb290IENBMB4XDTE2
MDEwMTAwMDAwMFoXDTM1MTIzMTIzNTk1OVowOTELMAkGA1UEBhMCUEExEDAOBgNV
BAoTB05vcmRWUE4xGDAWBgNVBAMTD05vcmRWUE4gUm9vdCBDQTCCAiIwDQYJKoZI
hvcNAQEBBQADggIPADCCAgoCggIBAMkr/BYhyo0F2upsIMXwC6QvkZps3NN2/eQF
kfQIS1gql0aejsKsEnmY0Kaon8uZCTXPsRH1gQNgg5D2gixdd1mJUvV3dE3y9FJr
XMoDkXdCGBodvKJyU6lcfEVF6/UxHcbBguZK9UtRHS9eJYm3rpL/5huQMCppX7kU
eQ8dpCwd3iKITqwd1ZudDqsWaU0vqzC2H55IyaZ/5/TnCk31Q1UP6BksbbuRcwOV
skEDsm6YoWDnn/II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Erb904mZfkIEmojC
VPhBHVQ9LHBAdM8qFI2kRK0IynOmAZhexlP/aT/kpEsEPyaZQlnBn3An1CRz8h0S
PApL8PytggYKeQmRhl499+6jLxcZ2IegLfqq41dzIjwHwTMplg+1pKIOVojpWA==
-----END CERTIFICATE-----
</ca>
key-direction 1
<tls-auth>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
e685bdaf659a25a200e2b9e39e51ff03
0fc72cf1ce07232bd8b2be5e6c670143
f51e937e670eee09d4f2ea5a6e4e6996
5db852c275351b86fc4ca892d78ae002
d6f70d029bd79c4d1c26cf14e9588033
cf639f8a74809f29f72b9d58f9b8f5fe
fc7938eade40e9fed6cb92184abb2cc1
0eb1a296df243b251df0643d53724cdb
5a92a1d6cb817804c4a9319b57d53be5
80815bcfcb2df55018cc83fc43bc7ff8
2d51f9b88364776ee9d12fc85cc7ea5b
9741c4f598c485316db066d52db4540e
212e1518a9bd4828219e24b20d88f598
a196c9de96012090e333519ae18d3509
9427e7b372d348d352dc4c85e18cd4b9
3f8a56ddb2e64eb67adfc9b337157ff4
-----END OpenVPN Static key V1-----
</tls-auth>
From here I want to delete all after <ca> tag
I tried various way, but every time the result is the same, I don't know what I do wrong
The last I tried is
echo "$SERVER_CONFIGURATION_FILE" | sed 's/<c[.\s\S\d\D\w\W]*//'
but remove only <ca and nothing more and the funny is that under regex101 this regex works
I feel pretty stupid but I can't find what I miss!
Any idea?
Please note that I'm under sh with busybox 1.30
Is this what you're trying to do?
$ awk '/<ca>/{exit} 1' file
client
dev tun
proto udp
remote 192.145.127.237 1194
resolv-retry infinite
remote-random
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ping 15
ping-restart 0
ping-timer-rem
reneg-sec 0
comp-lzo no
remote-cert-tls server
auth-user-pass
verb 3
pull
fast-io
cipher AES-256-CBC
auth SHA512
if your text is in a variable or coming from a pipe otherwise then just call it like this:
echo "$SERVER_CONFIGURATION_FILE" | awk '/<ca>/{exit} 1'
You don't need sed or awk for that. You can do it directly in the shell like this:
SERVER_CONFIGURATION_FILE="${SERVER_CONFIGURATION_FILE%%<ca>*}"
(Tested in dash; I assume busybox sh works the same way.)
${var%%pattern} expands to the contents of var, but with the longest suffix matching the glob pattern pattern stripped away.
The main problem with your sed attempt is that sed reads input one line at a time, so matches from one line wouldn't affect the other lines. (Also, your regex is slightly crazy and doesn't work like that in sed anyway.)
A working sed solution:
sed '/<ca>/{x;q}'
Or, perhaps more directly:
sed -n '/<ca>/q; p'
I.e. do not print by default; if line matches <ca>, quit; otherwise print and read the next line.

How to fix "the octet sequence #(130) cannot be decoded." in pgloader

I'm trying to migrate a database from sqlite to postgresql using pgloader.
My sqlite db is data.db, so i try this
pgloader ./var/data.db postgres://***#ec2-54-83-50-174.compute-1.amazonaws.com:5432/mydb?sslmode=require
Output:
pgloader version 3.6.1
sb-impl::*default-external-format* :UTF-8
tmpdir: #P"/var/folders/65/x6spw10s4jgd3qkhdq96bk8c0000gn/T/"
KABOOM!
2019-04-11T19:22:47.022000+01:00 NOTICE Starting pgloader, log system is ready.
FATAL error: :UTF-8 stream decoding error on #<SB-SYS:FD-STREAM for "file /Users/mackbookpro/Desktop/dev/www/Beyti/var/data.db" {1005892A93}>: the octet sequence #(130) cannot be decoded.
Date/time: 2019-04-11-18:22An unhandled error condition has been signalled: :UTF-8 stream decoding error on #<SB-SYS:FD-STREAM for "file /Users/mackbookpro/Desktop/dev/www/Beyti/var/data.db" {1005892A93}>: the octet sequence #(130) cannot be decoded.
An idea about this problem? thank you in advance
This is a character encoding issue.
The culprit "octet sequence #(130)" corresponded to "é" in my case, which was encoded as \x82.
iconv failed.
I replaced in the byte stream those corrupted \x82 with \x65 (ascii char "e"), and I got out of it.
<bad_file xxd -c1 -p | sed s/82/65/ | xxd -r -p > good_new_file
(cheers to Natacha on irc freenode #gcu :) )
Edit : French issues? same problem with #133 "à", same solution \x85 -> \x61
Edit 2 : A little generalization I just found :
The "octet sequence" pgloader refers to, is the decimal ranking of the ascii table. When you get higher than 127 in the "octet sequence", you step in the extended ascii table and generate errors.
I just got an issue with #144? It is \x90. replace :)

PostgreSQL - COPY FROM - "unacceptable encoding" error

I get an error when trying to use copy utility to extract data from csv file with UCS-2 LE BOM encoding (as reported by notepad++).
COPY pub.calls (............ )
FROM 'c:\IMPORT\calls.csv'
WITH
DELIMITER ','
HEADER
CSV
ENCODING 'UCS2';
The error is something like this
SQL Error [22023]Error The argument of encoding parameter should be
acceptable encoding name.
UCS-2 gives the same error.
For the list of supported charsets:
https://www.postgresql.org/docs/current/static/multibyte.html
or in psql type \encoding and dbl tab for autocomplete:
postgres=# \encoding
BIG5 EUC_JP GB18030 ISO_8859_6 JOHAB LATIN1 LATIN3 LATIN6 LATIN9 SJIS UTF8 WIN1252 WIN1255 WIN1258
EUC_CN EUC_KR GBK ISO_8859_7 KOI8R LATIN10 LATIN4 LATIN7 MULE_INTERNAL SQL_ASCII WIN1250 WIN1253 WIN1256 WIN866
EUC_JIS_2004 EUC_TW ISO_8859_5 ISO_8859_8 KOI8U LATIN2 LATIN5 LATIN8 SHIFT_JIS_2004 UHC WIN1251 WIN1254 WIN1257 WIN874

JasperReports Server: DB encoding issue - the Cyrillic symbols are not displaying

I'm trying to run report on JasperReports Server. My MySQL db encoding is cp1251.
The result of running report
� "Emika" Ltd, 3
������� 2012
?- must be the Russian symbols. I found solution to set URL in report datasource
jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=cp1251.
But it doesn't works. What I'm doing wrong?
Connection settings
are
Variable_name Value
character_set_client cp1251
character_set_connection cp1251
character_set_database cp1251
character_set_filesystem binary
character_set_result cp1251
character_set_server cp1251
character_set_system utf8
I resolve the problem. I set the parameter init-connect="SET NAMES utf8" in file /etc/mysql/my.cnf

Can I read Cyrillic (Russian) characters from the CLI in Groovy?

I have a Groovy script that takes user input from the CLI. The CLI supports Cyrillic characters and both the encoding and charset are in UTF-8. Yet, when Groovy reads input with Cyrillic characters, all it sees are "???????". Additionally, Groovy cannot create a directory or file with the given parameter. Does anyone have any ideas on forcing Groovy to accept the Cyrillic characters? Thanks.
Ensure the reader you're using is using the same encoding as your CLI. If they are, it could be a problem displaying the characters instead. You can verify the Unicode codepoints that groovy is getting like this:
// test.groovy
def input = System.in.withReader('UTF-8') { it.readLine() }
input.eachWithIndex { ch, index ->
println "$ch, ${Character.codePointAt(input, index)}"
}
Run this from the CLI:
$ echo $LANG
en_US.UTF-8
$ echo Здра́вствуйте | groovy test.groovy
З, 1047
д, 1076
р, 1088
а, 1072
́, 769
в, 1074
с, 1089
т, 1090
в, 1074
у, 1091
й, 1081
т, 1090
е, 1077