[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  os.env not working as I expected on yun
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

os.env not working as I expected on yun

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Jantje   Belgium  (2 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 14 May 2015 08:02 PM (UTC)
Message
Template:Arduino Please post Arduino-related questions to the Arduino Forum or to StackExchange: Arduino. This saves splitting questions and answers between this forum and the Arduino ones.


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:


export FOO=bar

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jantje   Belgium  (2 posts)  [Biography] 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
[Go to top] 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.


2,088 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]