3

I would like to make a Lua script that could run with arguments in Linux, for an example, lua foo.lua 25 would process the number 25 and give you an answer based off of that, my current program uses io.read to ask the user to enter a number, but I would like to do that at the same time I run the program.

Searching on the subject I did find this page http://www.lua.org/manual/5.1/manual.html#6 and haven't been able to make sense of it, this is the first program I've written, it's a happy number finder incase you are curious, thanks for the help.

  • Start the script's first line with #!/bin/bash and assuming the name of the shell script is lua_run.sh then chmod 775 lua_run.sh. What do you want the shell script to do, just pass arguments, test to see if arguments were passed, or something else? With a little more info, you'd get more help. – octopusgrabbus Dec 12 '11 at 17:51
  • Sorry, I thought you meant a shell script around a lua command. – octopusgrabbus Dec 12 '11 at 18:14

1 Answers1

3

The number given is available (as a string) in arg[1] in foo.lua.

lhf
  • 70,581
  • 9
  • 108
  • 149