|
David Given a écrit :
yes, works great... When i 've tried to do that, i had some bash errors. Probably due to an incorrect syntax...luc1an0 wrote: [...]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.
And another simply question : How to don't return exit code if function even return string, for exampleio.write(os.execute("pwd")) return this /home/fred 0I'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 !"pwd" was just an example... In fact, if I execute command which return a status code (like "test"), I want to get it. But if the command return a string, I just want to get these string without the status code.
Thanks a lot :)