2010-10-17 21:50:55 +02:00
|
|
|
|
|
|
|
|
|
/// ===========================================================
|
|
|
|
|
|
|
|
|
|
int executable_run(char cmd[], char args[])
|
|
|
|
|
{
|
|
|
|
|
|
2020-04-15 00:21:16 +02:00
|
|
|
|
char exec[FILENAME_MAX];
|
|
|
|
|
int result;
|
2010-10-17 21:50:55 +02:00
|
|
|
|
|
2020-04-15 00:21:16 +02:00
|
|
|
|
if ( '/' == cmd[0]) // if path is absolute
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
strcpy(exec, cmd);
|
|
|
|
|
if (!file_check(exec) ) // check file existense
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
file_not_found(cmd);
|
|
|
|
|
return FALSE;
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-15 00:21:16 +02:00
|
|
|
|
else
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
strcpy(exec, cur_dir); // check file in current directory
|
|
|
|
|
if (exec[strlen(exec)-1] != '/')
|
|
|
|
|
strcat(exec, "/"); // add slash
|
2010-10-17 21:50:55 +02:00
|
|
|
|
strcat(exec, cmd);
|
2020-04-15 00:21:16 +02:00
|
|
|
|
|
|
|
|
|
if ( !file_check(exec) ) // check file existense
|
|
|
|
|
{
|
|
|
|
|
strcpy(exec, "/rd/1/"); // check file on virtual disk
|
|
|
|
|
strcat(exec, cmd);
|
|
|
|
|
if ( !file_check(exec) ) // check file existense
|
|
|
|
|
{
|
2012-04-16 12:40:07 +02:00
|
|
|
|
file_not_found(cmd);
|
2010-10-17 21:50:55 +02:00
|
|
|
|
return FALSE;
|
2020-04-15 00:21:16 +02:00
|
|
|
|
}
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 00:21:16 +02:00
|
|
|
|
// if file exists:
|
2010-10-17 21:50:55 +02:00
|
|
|
|
|
2020-04-15 00:21:16 +02:00
|
|
|
|
// try to run as a program
|
|
|
|
|
result = program_run(exec, args);
|
|
|
|
|
if (result > 0)
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
if ( !program_console(result) )
|
2012-03-23 19:53:16 +01:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
LAST_PID = result;
|
|
|
|
|
#if LANG_ENG
|
|
|
|
|
printf (" '%s' started. PID = %d\n\r", cmd, result);
|
|
|
|
|
#elif LANG_RUS
|
|
|
|
|
printf (" '%s' <20><><EFBFBD><EFBFBD>饭. PID = %d\n\r", cmd, result);
|
|
|
|
|
#endif
|
2012-03-23 19:53:16 +01:00
|
|
|
|
}
|
2020-04-15 00:21:16 +02:00
|
|
|
|
return TRUE;
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
2020-04-15 00:21:16 +02:00
|
|
|
|
else
|
2010-10-17 21:50:55 +02:00
|
|
|
|
{
|
2020-04-15 00:21:16 +02:00
|
|
|
|
if ( script_check(exec) ) // if file is a valid script
|
|
|
|
|
{
|
|
|
|
|
return script_run(exec, args);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
#if LANG_ENG
|
|
|
|
|
printf ("Error in '%s' : script must start with #SHS line\n\r", cmd);
|
|
|
|
|
#elif LANG_RUS
|
|
|
|
|
printf ("<EFBFBD>訡<EFBFBD><EFBFBD> <20> '%s' : <20><>ਯ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>稭<EFBFBD><E7A8AD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>窨 #SHS\n\r", cmd);
|
|
|
|
|
#endif
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-10-17 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// ===========================================================
|
2013-02-17 16:22:51 +01:00
|
|
|
|
|