From 43055ae6a74afd5b827f9198eafa65640da8e374 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 4 Sep 2019 23:29:03 +0200 Subject: [PATCH] searchFile for cmdscripts --- client/proxmark3.c | 16 +++++++++++----- include/common.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/proxmark3.c b/client/proxmark3.c index cb3444ad7..7e732360f 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -27,6 +27,7 @@ #include "cmdhw.h" #include "whereami.h" #include "comms.h" +#include "fileutils.h" //#include "usart.h" static void showBanner(void) { @@ -95,11 +96,16 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) { if (script_cmds_file) { - sf = fopen(script_cmds_file, "r"); - if (sf) - PrintAndLogEx(SUCCESS, "executing commands from file: %s\n", script_cmds_file); - else - PrintAndLogEx(ERR, "could not open " _YELLOW_("%s") "...", script_cmds_file); + char *path; + int res = searchFile(&path, CMD_SCRIPTS_SUBDIR, script_cmds_file, ".cmd", false); + if (res == PM3_SUCCESS) { + sf = fopen(path, "r"); + if (sf) + PrintAndLogEx(SUCCESS, "executing commands from file: %s\n", path); + else + PrintAndLogEx(ERR, "could not open " _YELLOW_("%s") "...", path); + free(path); + } } char *my_history_path = NULL; diff --git a/include/common.h b/include/common.h index bdda44aae..f13f5f99a 100644 --- a/include/common.h +++ b/include/common.h @@ -24,6 +24,7 @@ #define PM3_USER_DIRECTORY PATHSEP ".proxmark3" PATHSEP // PM3 subdirectories: +#define CMD_SCRIPTS_SUBDIR "cmdscripts" PATHSEP #define DICTIONARIES_SUBDIR "dictionaries" PATHSEP #define LUA_LIBRARIES_SUBDIR "lualibs" PATHSEP #define LUA_SCRIPTS_SUBDIR "luascripts" PATHSEP