|
|
||
|
luc1an0 wrote:yes, works great... When i 've tried to do that, i had some bash errors. Probably due to an incorrect syntax...
[...]
My question can be very stupid, but I want to execute some shell commands with a pipe ( | ) like that :
os.execute(ps aux | grep my_program) or a generic way :
os.execute("my_command" "my_args" | another_command | ....)
I may be missing something here, but:
os.execute("ps aux | grep my_program")
...should work.
Thanks !And another simply question : How to don't return exit code if function even return string, for example
io.write(os.execute("pwd")) return this
/home/fred
0
I'm not sure what you're asking for here. Do you want to stop pwd printing it's output directly to the console and instead let Lua capture it as a string? If so, use io.popen:
local f = io.popen("pwd") -- runs command local l = f:read("*a") -- read output of command print(l) f:close()
Or did you mean something else?
Thanks a lot :)