Reputation: 488
On OpenWRT, I have a Lua script on_new_device.lua
that runs fine if I execute lua on_new_device.lua
; however, I'd like to run it simply by executing ./on_new_device.lua
.
Executing ./on_new_device.lua
returns this error...
root@router:~# ./on_new_device.lua
-ash: ./on_new_device.lua: not found
The file has execute permissions...
root@router:~# ls -la ./on_new_device.lua
-rwxrwxrwx 1 root root 1094 Jun 18 11:06 ./on_new_device.lua
The file starts with #!/usr/bin/lua
...
root@router:~# head -1 ./on_new_device.lua
#!/usr/bin/lua
How can I execute this file directly?
Upvotes: 3
Views: 2013
Reputation: 488
Bah, the problem was that the lua script was created on a Windows machine and had \r\n line endings. Saving the file with \n line endings solved the issue.
Upvotes: 0
Reputation: 1338
Can you wrap it in a script?
Copy this into a test.ash file:
#!/bin/ash
/usr/bin/lua /[path]/on_new_device.lua
Then chmod 755 on test.ash, and then you can run:
./test.ash
Upvotes: 4