searchFile for cmdscripts

This commit is contained in:
Philippe Teuwen 2019-09-04 23:29:03 +02:00
commit 43055ae6a7
2 changed files with 12 additions and 5 deletions

View file

@ -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");
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", script_cmds_file);
PrintAndLogEx(SUCCESS, "executing commands from file: %s\n", path);
else
PrintAndLogEx(ERR, "could not open " _YELLOW_("%s") "...", script_cmds_file);
PrintAndLogEx(ERR, "could not open " _YELLOW_("%s") "...", path);
free(path);
}
}
char *my_history_path = NULL;

View file

@ -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