I am using latest SciTE on Ubuntu 9.10 64 bit.
I would like to execute this lua command:
os.execute('mkdir /newdir_${HOSTNAME}')
The result is a new directory: /newdir_
It seems that the value of ${HOSTNAME} cannot be retrieved from LUA.
Executing from command line works perfect:
#mkdir /newdir_${HOSTNAME}
New directory created: /newdir_myhost
What could be the issue that I cannot use bash global/environment
variables from LUA?
Thanks
Istvan
Note: that's Lua (Portuguese common name meaning 'moon') not LUA (Lua is Unlikely to be an
Acronym... :)) Common mistake coming from who know where.
You should try:
os.execute('mkdir /newdir_' .. props["HOSTNAME"])
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
props["HOSTNAME"] is empty, result is same as before: /newdir_
Thanks
Istvan
Ah, it works for me on Windows, I supposed it was the same on Linux.
> I am using latest SciTE on Ubuntu 9.10 64 bit.
> What could be the issue that I cannot use bash
> global/environment variables from LUA?
It looks like bash does not export "HOSTNAME" by default.
print(os.getenv("PATH")) -- works
print(os.getenv("HOSTNAME")) -- fails
You could add "export HOSTNAME" to you ~/.bashrc file,
or put it on the scite command-line:
HOSTNAME=$HOSTNAME SciTE ...
or you could try a script something like:
local hostname="unknown"
local hn=io.popen("hostname")
if hn then
hostname=hn:read("*l")
hn:close()
end
print(hostname)
- Jeff
I've lots of variables in ~/.bashrc but they are not visible even they
are exported.
> or you could try a script something like:
It works, thank you.
Regards,
Istvan