parsed.org

Tips by tag: binary

Inserting Binaries with Psycopg by xinu on Jan 12, 2005 01:41 PM

Use the psycopg.Binary() function to escape the binary data:

>>> db = psycopg.connect("dbname=%s user=%s" % (database, user))
>>> db.autocommit(True)
>>> cursor = db.cursor()
>>> file = "/path/to/binary_file.jpg"
>>> fd = open(file, "r")
>>> contents = fd.read(os.stat(file)[6])
>>> fd.close()
>>> cursor.execute("INSERT INTO pr0n (image) VALUES (%s)", (psycopg.Binary(contents)))
binarybyteacursordbapiescapeinteractivelanguagespostgresqlprogrammingpsycopgpython
Using 'strings' for Paths in a Binary by xinu on Sep 13, 2005 02:34 PM

If you need to discover on which paths a binary depends, you can sometimes run strings on it and grep for everything starting with a slash:

# strings /usr/sbin/named | grep ^/
/lib/ld-linux.so.2
/etc/named.conf
/etc/rndc.key
/etc/lwresd.conf
/etc/resolv.conf
/var/run/named/named.pid
/var/run/named/lwresd.pid
/dev/null
binaryconfigurationgrepprocessshellstrings
RSS