#!/bin/csh
echo "Insert the GazelleProxy TLS  connection_id :"
set reponse=$<
echo "Insert the filepath where you want to save the HexData of the communication:"
set filepath=$<
psql -c "COPY (SELECT encode(messagereceived,'hex') FROM pxy_abstract_message WHERE connection_id=$reponse ORDER BY index) TO '$filepath'" -U net.ihe.gazelle.gazelle -d net.ihe.gazelle.gazelle-proxy
sed -i ':a;$'!'{N;s/\n//;ba;}' $filepath
truncate -s -1 $filepath
chmod +w $filepath
