have a problem:
local stat = assert(os.execute("/usr/bin/pgrep -f 'tail -F /opt/aaa' >& /dev/null"))
print(stat) --> 0
But when I type pgrep -f 'tail -F /opt/aaa' >& /dev/null in bash, and then call echo $? it returns 1. Has anybody encountered this before, or know the reason why ;-) what happened?
Doesn't seem to be a Lua problem to me, os.execute is just wrapping a call to system:
static int os_execute (lua_State *L) {
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
return 1;
}
If you try the C alternative you have the correct result code?
#include <stdio.h>
#include <string.h>
int main ()
{
char command[100];
int result;
strcpy( command, "/usr/bin/pgrep -f 'tail -F /opt/aaa' >& /dev/null" );
result = system(command);
return(0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With