add local executable commands

This commit is contained in:
KF7EEL 2022-03-01 19:47:17 -08:00
parent 3d877f6fc5
commit eabf7df017
2 changed files with 16 additions and 9 deletions

View File

@ -98,6 +98,9 @@ import traceback
from socket import gethostbyname from socket import gethostbyname
from data_gateway_local_commands import LOCAL_COMMANDS
import subprocess
################################# #################################
@ -794,15 +797,15 @@ def process_sms(_rf_src, sms, call_type, system_name):
logger.error('User APRS messaging disabled.') logger.error('User APRS messaging disabled.')
## if call_type == 'vcsbk': ## if call_type == 'vcsbk':
## send_sms(False, 9, 9, 9, 'group', 'APRS Messaging must be enabled. Send command "@APRS ON" or use dashboard to enable.') ## send_sms(False, 9, 9, 9, 'group', 'APRS Messaging must be enabled. Send command "@APRS ON" or use dashboard to enable.')
elif '%' in parse_sms[0]:
try:
## if parse_sms[0][1:] in LOCAL_COMMANDS:
## try: logger.info('Executing command/script.')
## if sms in cmd_list: subprocess.Popen(LOCAL_COMMANDS[parse_sms[0][1:]], shell=False)
## logger.info('Executing command/script.') except Exception as error_exception:
## os.popen(cmd_list[sms]).read() logger.info('Exception. Command possibly not in list, or other error.')
## packet_assembly = '' logger.info(error_exception)
## except Exception as error_exception:
## logger.info('Exception. Command possibly not in list, or other error.')
## logger.info(error_exception)
## logger.info(str(traceback.extract_tb(error_exception.__traceback__))) ## logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
## packet_assembly = '' ## packet_assembly = ''
else: else:

View File

@ -0,0 +1,4 @@
# Python dictionary of commands that can be executed via SMS
# 'SMS':'COMMAND TO EXECUTE'
LOCAL_COMMANDS = {'ls':'ls',
'pwd':'pwd'}