Convert Sqlite DB To TXT Cookies Format
Join the DZone community and get the full member experience.
Join For Free
#!/bin/bash
set -e
# Replace a column field for each line in stdin
replace_column_value() {
awk "BEGIN{OFS=FS=\"$1\"} {\$$2 = ((\$$2==\"$3\")?\"$4\":\"$5\"); print}"
}
# Convert a Mozilla sqlite cookie file to the old txt format
mozilla_cookies_sqlite2txt() {
echo "# Netscape HTTP Cookie File"
echo ".mode tabs
SELECT host, (host GLOB '.*'), path, 'FALSE', expiry, name, value
FROM moz_cookies;" | sqlite3 "$1" | \
replace_column_value "\t" 2 "1" "TRUE" "FALSE" | \
recode iso8859-1..utf-8 | tr -d '[áéÃóúà èìòù]'
}
FILE=$1
mozilla_cookies_sqlite2txt "$FILE"
SQLite
Convert (command)
Opinions expressed by DZone contributors are their own.
Comments