[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA os.execute help
- From: James Graves <ansible@...>
- Date: Sun, 15 Aug 2010 04:26:16 -0500
On Sun, Aug 15, 2010 at 11:17:35AM +0200, soly® wrote:
> I have the following lua code
>
>
> act = {"dsm", "nn10", "nn9"};
> for b = 1, table.getn(act), 1 do
> zz = act[b] ;
> os.execute("echo 'zz' >>\etc\putty\putty1.log")
> end
>
> i really want to add the value of the variable 'zz' in the echo
> command but the command os.execute("echo 'zz'
> >>\etc\putty\putty1.log") print the word zz not the value of the
> variable zz !!!
>
> plz help me to use the os.execute("echo to get the value of the
> variable zz in the file
You can't just include the variable in the string. Lua is not like
the shell interpreter.
Instead, you want to concatenate the contents of the zz variable with
the rest of the string going into os.execute().
So you want something like this instead:
os.execute("echo '" .. zz .. "' >>\etc\putty\putty1.log")
James