From aff87896e8324656ce7bfab2db3d9b24ea22844f Mon Sep 17 00:00:00 2001
From: "Robin P. Clark" <r.clark@energytechnologycontrol.com>
Date: Tue, 21 Jan 2025 10:26:09 +0000
Subject: [PATCH] ssh tunnels

---
 README_harveys_to_file_ssh_tunnel.txt | 56 +++++++++++++++++++++++++++
 ppt_to_png.sh                         | 28 ++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 README_harveys_to_file_ssh_tunnel.txt
 create mode 100755 ppt_to_png.sh

diff --git a/README_harveys_to_file_ssh_tunnel.txt b/README_harveys_to_file_ssh_tunnel.txt
new file mode 100644
index 0000000..7e35c81
--- /dev/null
+++ b/README_harveys_to_file_ssh_tunnel.txt
@@ -0,0 +1,56 @@
+
+
+
+
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+# 21JAN2025: 
+Instructions for VNC and file logging 
+via an ssh tunnel to an ETC 6075 touchscreen
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+
+
+# Login to dev using ssh -X
+
+
+
+
+-------------------------------------------------------
+# file Logging
+-------------------------------------------------------
+
+To log data files/can 
+On dev
+
+dev$ ssh -p 1235 root@localhost "./can_rx | egrep 'O2|F1DF' " >> touchscreen_can_log.txt
+
+This will log to dev data streamed from the touch screen via the shh tunnel.
+
+
+
+
+-------------------------------------------------------
+# VNC
+-------------------------------------------------------
+
+# This assumes the reverse_tunnel.sh is running on the target touch screen
+
+to get this running log in from dev
+dev$ ssh -p1235 root@localhost
+# login password....
+# 
+# more tunnel_vnc.sh
+ssh -y -N -l touchscreen -R 1236:localhost:5900 dev.energytechnologycontrol.com
+# ./tunnel_vnc.sh &
+# exit # back to dev
+
+display a VNC copy of the touchscreen GUI.
+
+$dev vncviewer localhost:1236 
+
+VNC viewer should display. Leave terminal session logged in.
+
+
+
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+RPC 21JAN2025
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
diff --git a/ppt_to_png.sh b/ppt_to_png.sh
new file mode 100755
index 0000000..2116eec
--- /dev/null
+++ b/ppt_to_png.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/bash
+
+# Generate temporary file safely
+temp_file=$(mktemp)
+ppt "$1" > "$temp_file"
+
+# Count lines directly
+line_count=$(wc -l < "$temp_file")
+
+# Calculate image height (e.g., 20 pixels per line, with a minimum height)
+line_height=20
+image_height=$((line_count * line_height))
+[ "$image_height" -lt 70 ] && image_height=70  # Ensure a minimum height of 70 pixels
+
+# Generate image with dynamic height and fixed-width font
+convert \
+    -size 165x${image_height} \
+    xc:lightyellow \
+    -font Courier \
+    -pointsize 12 \
+    -fill blue \
+    -gravity center \
+    -draw "text 0,0 '$(cat "$temp_file")'" \
+    image.png
+
+# Clean up temporary file
+rm "$temp_file"
+