unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Eval environment variables using Lisp code
@ 2006-04-19 10:12 Ismael Valladolid Torres
  0 siblings, 0 replies; 2+ messages in thread
From: Ismael Valladolid Torres @ 2006-04-19 10:12 UTC (permalink / raw)


In my setup, I run ssh-agent making it create a script that can be
sourced from any shell giving it access to the agent:

$ ssh-agent -a /tmp/.ssh-socket >/tmp/.ssh-script
$ cat /tmp/.ssh-script
SSH_AUTH_SOCK=/tmp/.ssh-socket; export SSH_AUTH_SOCK;
SSH_AGENT_PID=148; export SSH_AGENT_PID;
echo Agent pid 148;

To be able to use Tramp, I'd need emacs to eval that shell code so
environment variables are properly defined. Can this be done via Lisp
code in my .emacs?

This is NT Emacs and ssh is the Cygwin version. So running ssh-agent
via the window manager is not an option, and making ssh not use the
agent and ask for a password instead isn't, either. If I eval that
code on a Bash shell and run emacs from it, it works, but I'd like it
to work when using the Emacs icon.

Thanks in advance for any idea.

Cordially, Ismael
-- 
 Ismael Valladolid Torres       OpenPGP key ID: 0xDE721AF4
  [^[$B$?$S$?$S$9$_$^$;$s^[(B]       Jabber ID: ivalladt@jabberes.org

  http://lamediahostia.blogspot.com  =?iso-2022-jp?B?GyJE0hREjAGyhC?=

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Eval environment variables using Lisp code
       [not found] <mailman.562.1145441543.9609.help-gnu-emacs@gnu.org>
@ 2006-04-19 11:10 ` Phillip Lord
  0 siblings, 0 replies; 2+ messages in thread
From: Phillip Lord @ 2006-04-19 11:10 UTC (permalink / raw)


>>>>> "IVT" == Ismael Valladolid Torres <ivalladolidt@terra.es> writes:

  IVT> In my setup, I run ssh-agent making it create a script that can
  IVT> be sourced from any shell giving it access to the agent:

  IVT> $ ssh-agent -a /tmp/.ssh-socket >/tmp/.ssh-script $ cat
  IVT> /tmp/.ssh-script SSH_AUTH_SOCK=/tmp/.ssh-socket; export
  IVT> SSH_AUTH_SOCK; SSH_AGENT_PID=148; export SSH_AGENT_PID; echo
  IVT> Agent pid 148;

  IVT> To be able to use Tramp, I'd need emacs to eval that shell code
  IVT> so environment variables are properly defined. Can this be done
  IVT> via Lisp code in my .emacs?

  IVT> This is NT Emacs and ssh is the Cygwin version. So running
  IVT> ssh-agent via the window manager is not an option, and making
  IVT> ssh not use the agent and ask for a password instead isn't,
  IVT> either. If I eval that code on a Bash shell and run emacs from
  IVT> it, it works, but I'd like it to work when using the Emacs
  IVT> icon.

  IVT> Thanks in advance for any idea.


I had the same problem; actually it happens with linux as well, when
launching from the desktop icon rather than elsewhere. 

I use the following, rather horrible, approach. First, I use keychain
rather than ssh-agent directly. This drops a similar script into
.keychain/hostname-sh. I just parse this out with emacs, and use
setenv to set the environment variables. Not very neat, but it works. 

You'll need to fiddle the lisp to get it to work without keychain, but
it should be straight forward. 

(defun phil-parse-keychain()
  "Parse keychain files, and set environment variables appropriately."
  (interactive)
  (with-temp-buffer
    (insert-file 
     (concat "~/.keychain/" (downcase (system-name))
             "-sh"))
    (switch-to-buffer (current-buffer))
    (phil-parse-keychain-split-line)
    (forward-line)
    (phil-parse-keychain-split-line)))

(defun phil-parse-keychain-split-line()
  (let ((env 
         (split-string (buffer-substring-no-properties
                        (line-beginning-position) (line-end-position))
                       "[=;]")))
    (setenv (nth 0 env) (nth 1 env))))

(phil-parse-keychain)   


Cheers

Phil

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-19 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-19 10:12 Eval environment variables using Lisp code Ismael Valladolid Torres
     [not found] <mailman.562.1145441543.9609.help-gnu-emacs@gnu.org>
2006-04-19 11:10 ` Phillip Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).