monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Calling the shell from a hook


From: Thomas Moschny
Subject: Re: [Monotone-devel] Calling the shell from a hook
Date: Fri, 17 Nov 2006 13:09:57 +0100
User-agent: KMail/1.9.5

On Friday 17 November 2006 12:01, William Uther wrote:
>    I'm just playing with monotone to see if I want to do some
> projects with it.  Is there a way to get the output of a another
> process from within one of the lua hooks?
> [...]
> I was hoping something like this would work:
>
> function get_passphrase(keypair_id)
>      pass = execute("/Users/willu/bin/getPassword", "monotoneKey")
>      print("finished executing")
>      print(pass)
>      return pass
> end

You could try something like this:

function get_passphrase(keypair_id)
  local f, fname = temp_file()
  if f ~= nil then
    local stat = execute("sh", "-c", "/Users/willu/bin/getPassword" 
                         .. "monotoneKey" .. " > " .. fname)
    if stat == 0 then
      passwd = f:read()
    end
    os.remove(fname)
    if passwd ~= nil then
      return passwd
    end
  end
end

This is untested, and has the disadvantage that it stores the password in a 
file for a short time, maybe someone with more lua knowledge can come up with 
a better solution using a pipe or so.

- Thomas M.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]