summaryrefslogtreecommitdiff
path: root/migdon
diff options
context:
space:
mode:
Diffstat (limited to 'migdon')
-rwxr-xr-xmigdon/bash_migdeon.sh17
-rwxr-xr-xmigdon/migdon.py28
-rw-r--r--migdon/migdon_wrapper.sh2
3 files changed, 47 insertions, 0 deletions
diff --git a/migdon/bash_migdeon.sh b/migdon/bash_migdeon.sh
new file mode 100755
index 0000000..95bd7ca
--- /dev/null
+++ b/migdon/bash_migdeon.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+PPID=`ps -o ppid -p $$`
+
+echo parent PID $PPID
+
+PTTY=`ps -p $PPID -o tty --no-headers`
+
+echo parent TTY $PTTY
+
+while IFS= read -r line; do
+ echo "read one line";
+done
+
+while IFS= read -r line; do
+ echo "read one line 2";
+done < /dev/$PTTY
diff --git a/migdon/migdon.py b/migdon/migdon.py
new file mode 100755
index 0000000..3e03193
--- /dev/null
+++ b/migdon/migdon.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import fileinput
+import os
+import sys
+import shlex
+import subprocess
+import re
+
+colourFormat = '\033[{0}m'
+colourStr = colourFormat.format(32)
+resetStr = colourFormat.format(0)
+
+#while True:
+# try:
+# c = sys.stdin.buffer.read(1)
+# except EOFError:
+# print("EOF")
+# break;
+# print(c)
+# sys.stdout.buffer.write(c)
+
+for line in fileinput.input():
+# print re.sub(r'([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})', colourStr+ r'\1' + resetStr, line),
+ ips=re.findall(r'([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})', line)
+ for ip in ips:
+ print "ipv4 detected: "+colourStr+ip+resetStr
+
diff --git a/migdon/migdon_wrapper.sh b/migdon/migdon_wrapper.sh
new file mode 100644
index 0000000..8f79f06
--- /dev/null
+++ b/migdon/migdon_wrapper.sh
@@ -0,0 +1,2 @@
+TTY=$(tty)
+bash | ./migdon.py > $TTY