steptail.com

Does expecting the unexpected make the unexpected the expected?

User Tools

Site Tools


guides:virtual_modem:script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
guides:virtual_modem:script [2019-11-19 00:04]
omolini
guides:virtual_modem:script [2020-02-27 23:20]
omolini [3.sh]
Line 18: Line 18:
 # -------------------------------- # --------------------------------
 # Oliver Molini 2019 # Oliver Molini 2019
 +#
 +# Billy Stoughton II for bug fixes and contributions
 # #
 # Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License # Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
 # https://​creativecommons.org/​licenses/​by-nc-sa/​4.0/​ # https://​creativecommons.org/​licenses/​by-nc-sa/​4.0/​
-#+
 # Tested working out of box with the following host configurations:​ # Tested working out of box with the following host configurations:​
 # #
Line 49: Line 51:
 vmodver=1.4.1 vmodver=1.4.1
  
-# CONFIGURATION ​VARIABLES+# CONFIGURATION
 # ----------------------- # -----------------------
 # Variable: serport # Variable: serport
Line 71: Line 73:
 # baud=57600 # baud=57600
 # #
-#baud 9600+#baud=9600
 #baud=38400 #baud=38400
 baud=57600 baud=57600
Line 82: Line 84:
  
 # Variable: resultverbose # Variable: resultverbose
-# Controls default ​behaviour ​when printing result +# Controls default ​behavior ​when printing ​Hayes result 
-# codes. When 0, will print result codes in numerical +# codes. ​ 
-form. When 1, will print result codes in english.+When 0, prints ​result codes in numerical form. (eg. 0) 
 +When 1, prints ​result codes in english. ​(eg. CONNECT)
 # Default is 1. # Default is 1.
 resultverbose=1 resultverbose=1
 +
 +# Variable: TERM
 +# Tells the script and environment which type of terminal to emulate.
 +# It is only useful to change this, if you're using a serial ​
 +# terminal to connect to this script. If you're connecting form a ANSI 
 +# cabable machine such as DOS, you may want to use TERM="​ansi"​
 +#
 +TERM="​vt100"​
  
 # EXPORT SHELL VARS # EXPORT SHELL VARS
Line 92: Line 103:
 export serport export serport
 export baud export baud
 +export TERM
  
 # FUNCTIONS # FUNCTIONS
Line 147: Line 159:
  
     #     #
-    # --- MODEM EMULATION ---+    # --- HAYES EMULATION ---
     #     #
     if [[ $cmd == AT* ]]; then     if [[ $cmd == AT* ]]; then
Line 222: Line 234:
             exec 99>&​-             exec 99>&​-
             # Execute dialed script             # Execute dialed script
-            /sbin/getty -8 -L $serport $baud vt100 -n -l "​./​$number.sh"​+            /sbin/getty -8 -L $serport $baud $TERM -n -l "​./​$number.sh"​
             # Reset serial settings             # Reset serial settings
             ttyinit             ttyinit
Line 317: Line 329:
 #!/bin/bash #!/bin/bash
 # RUN PPPD DAEMON # RUN PPPD DAEMON
 +#
 +# Oliver Molini 2019
 +
 +# Billy Stoughton II for bug fixes and contributions
 +#
 +# Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
 +# https://​creativecommons.org/​licenses/​by-nc-sa/​4.0/​
 # #
 # Note on PPPD settings: # Note on PPPD settings:
Line 322: Line 341:
 # - Make sure DNS servers are defined (add ms-dns 1.2.3.4 twice) # - Make sure DNS servers are defined (add ms-dns 1.2.3.4 twice)
 # #
 +
 +# Variable: etherp
 +# Specify the ethernet device to use to connect to your network.
 +
 +# Default: ​   etherp=eth0
 +etherp=eth0
 +
 # Variable: lcpidle # Variable: lcpidle
 # Specifies the idle timeout period in seconds for lcp-echo-interval. # Specifies the idle timeout period in seconds for lcp-echo-interval.
Line 328: Line 354:
 # #
 # Default: ​   lcpidle=5 # Default: ​   lcpidle=5
-# 
 lcpidle=5 lcpidle=5
  
Line 349: Line 374:
  
 # Share eth0 over ppp0 # Share eth0 over ppp0
-iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE +iptables -t nat -A POSTROUTING -o $etherp ​-j MASQUERADE 
-iptables -t filter -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,​ESTABLISHED -j ACCEPT +iptables -t filter -A FORWARD -i ppp0 -o $etherp ​-m state --state RELATED,​ESTABLISHED -j ACCEPT 
-iptables -t filter -A FORWARD -i eth0 -o ppp0 -j ACCEPT+iptables -t filter -A FORWARD -i $etherp ​-o ppp0 -j ACCEPT
  
 # Run PPP daemon and establish a link. # Run PPP daemon and establish a link.
Line 382: Line 407:
 echo "Thank you for visiting! Bye!" echo "Thank you for visiting! Bye!"
 sleep 2 sleep 2
 +</​code>​
 +
 +===== 3.sh =====
 +This example script allows VT100 compatible terminal access to the web by way of running lynx as soon as the number "​3"​ is dialed with "​ATD3"​. It demonstrates how to add a Linux based web browser for simple terminals.
 +
 +<code bash 3.sh>
 +#!/bin/bash
 +#
 +echo "​Terminal type set to $TERM. Running Lynx ..."
 +lynx
 </​code>​ </​code>​
  
guides/virtual_modem/script.txt · Last modified: 2022-12-28 03:32 by omolini