xfer.sh

From Perl Marten, 5 Years ago, written in Plain Text, viewed 204 times.
URL https://paste.steamr.com/view/287eca75 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. stty -echo
  4. dmesg -n 1
  5.  
  6. function chksum (){
  7.         echo -n "$1" | md5sum | awk '{print $1}'
  8. }
  9.  
  10. function tx_data (){
  11.         File="$1"
  12.        
  13.         if [ ! -f $File ] ; then
  14.                 echo "File $File not found."
  15.         fi
  16.        
  17.         md5sum $File | awk '{print $1}'
  18.  
  19.         cat $File | base64 | while read -r x ; do
  20.                 Sum=$(chksum "$x")
  21.  
  22.                 while true ; do
  23.                         # Send the data
  24.                         echo "$x:$Sum"
  25.  
  26.                         read X < /dev/ttyS0
  27.                         X=$(echo "$X" | tr -d '\n')
  28.                         if [[ "$X" == "$1" ]] ; then
  29.                                 break
  30.                         elif [[ "$X" == "quit" ]] ; then
  31.                                 exit
  32.                         fi
  33.                 done
  34.         done
  35.        
  36.         echo "EOF"
  37. }
  38.  
  39. tx_data $@

Reply to "xfer.sh"

Here you can reply to the paste above