Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a command-line command with Linux

Tags:

arguments

lua

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.

like image 218
user1094239 Avatar asked May 26 '26 05:05

user1094239


1 Answers

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

like image 61
lhf Avatar answered May 28 '26 14:05

lhf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!