X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/86724c17c9914f495e2a7df729d4fe65a9746d82..00848e096b408a43786ea283d4e77d32189994b9:/client/cmdscript.c?ds=sidebyside diff --git a/client/cmdscript.c b/client/cmdscript.c index 730f4e96..7b0e9000 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -17,7 +17,6 @@ #include "proxmark3.h" #include "scripting.h" -#include "data.h" #include "ui.h" #include "graph.h" #include "cmdparser.h" @@ -30,7 +29,6 @@ #include #include - static int CmdHelp(const char *Cmd); static int CmdList(const char *Cmd); static int CmdRun(const char *Cmd); @@ -77,7 +75,13 @@ int CmdList(const char *Cmd) { DIR *dp; struct dirent *ep; - dp = opendir ("./scripts/"); + char const * exedir = get_my_executable_directory(); + if (exedir == NULL) + return 0; + char script_directory_path[strlen(exedir) + strlen(LUA_SCRIPTS_DIRECTORY) + 1]; + strcpy(script_directory_path, exedir); + strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY); + dp = opendir(script_directory_path); if (dp != NULL) { @@ -149,17 +153,19 @@ int CmdRun(const char *Cmd) suffix = ".lua"; } - char buf[256]; - snprintf(buf, sizeof buf, "./scripts/%s%s", script_name, suffix); - - printf("--- Executing: %s, args'%s'\n",buf,arguments); + char script_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1]; + strcpy(script_path, get_my_executable_directory()); + strcat(script_path, LUA_SCRIPTS_DIRECTORY); + strcat(script_path, script_name); + strcat(script_path, suffix); + printf("--- Executing: %s%s, args '%s'\n", script_name, suffix, arguments); // run the Lua script - int error = luaL_loadfile(lua_state, buf); + int error = luaL_loadfile(lua_state, script_path); if(!error) {