Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ os.env not working as I expected on yun
|
os.env not working as I expected on yun
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Jantje
Belgium (2 posts) Bio
|
| Date
| Thu 14 May 2015 06:05 PM (UTC) |
| Message
| Hi Nick
As we discussed a long time ago I have been using lua on yun and lately I ported a ash script to lua.
The performance boost is huge!!! So me really happy.
However I bumped in a wierd thing. It seems that environment variables that have been created during on the command prompt before lua is started are not found by lua.
In the following dump DumpFile was created by running a script.
root@Marvin2:/www/cgi-bin/jantje# echo $DumpFile
/tmp/jantje/ttyATH0/dump.txt
root@Marvin2:/www/cgi-bin/jantje# lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio (double int32)
> print(os.getenv("DumpFile"))
nil
> print(os.getenv("HOME"))
/root
As you can see from the log above the OS knows the environment variable DumpFile but Lua does not.
Can you help me out on this one?
Txs
Jantje | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 14 May 2015 08:02 PM (UTC) |
| Message
|
Disclaimer: I don't have a Yun and know nothing about programming them.
Although this looks like a Unix problem. I think scripts have to export environment variables if you want to use them later.
Something like:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jantje
Belgium (2 posts) Bio
|
| Date
| Reply #2 on Thu 14 May 2015 08:57 PM (UTC) |
| Message
| Txs
spot on.
root@Marvin2:/www/cgi-bin/jantje# . ./SetGlobalSettings.sh
root@Marvin2:/www/cgi-bin/jantje# echo $DumpFile
/tmp/jantje/ttyATH0/dump.txt
root@Marvin2:/www/cgi-bin/jantje# export DumpFile=${DumpFile}
root@Marvin2:/www/cgi-bin/jantje# lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio (double int32)
> print(os.getenv("DumpFile"))
/tmp/jantje/ttyATH0/dump.txt
I never really understood the concept of export. I think my understanding just increased :-))
Indeed yun is a linux (openwrt)
Jantje | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,199 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top