mario
mario

Reputation: 385

Bash script is not being executed on .lua, exit status 7 (Arg list too long)

The .lua file is being executed because i saw the strings from m.log() in my log but the bash code is not being executed. Why? There's something i'm missing? Also there's no errors in the logs about the command in os.execute().

#!/usr/bin/lua

function main()
m.log(1,"Starting script execution \n")
os.execute ("route add xx.xxx.xxx.xxx reject")
## i also tried os.execute ("/path/to/file.sh") and giving permision to execute with chmod +x filename.sh
m.log(1,"Script execution finished\n")
end

NOTE: I executed the command from os.execute() directly in my Command Prompt, and the IP was added to the route, so there's something wrong in my lua code...

I changed the permisions to 777 from the folder/file that have the .lua and .sh file only to test if it was a permision issue, and nothing changed, i also tried to change the owner and usergroup.

Edit - This one bellow was not working because it was on the /root/ folder, so i needed to moved it to /var/www/.

os.execute ("/path/to/file.sh")

But the bash code is not being executed, the os.execute is returning exit status 7 (Arg list too long), I searched about it and i realized that it's because the entire bash code is being executed inside quote marks: Why do I get "/bin/sh: Argument list too long" when passing quoted arguments?

How can i fix it?

Upvotes: 2

Views: 4680

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26744

You should check the result of os.execute, as it returns the exit status of the command as one of the results.

You can also use io.popen to run your script and check the generated output.

Upvotes: 1

Related Questions