Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# btsync service
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="mendel"
DAEMON=/usr/bin/btsync
start() {
for btsuser in $BTSYNC_USERS; do
HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
config=$HOMEDIR/.sync/config.json
@mmyjona
mmyjona / gist:3917268
Created October 19, 2012 10:03
ping with python popen
##mmyjona2012-10-19 18:02:38
from subprocess import *
import subprocess
import re
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = Popen(["ping", "-n", "3", "baidu.com"],startupinfo=startupinfo, stdout=PIPE).communicate()[0]
regex = re.compile(r"from\s(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b).*bytes=(\d*).*time=(\d*).*TTL=(\d*)")
r = regex.findall(output)
print r