| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <44F4C2C4.6080807@lapo.it> |
| Date: | Wed, 30 Aug 2006 00:42:12 +0200 |
| From: | Lapo Luchini <lapo AT lapo DOT it> |
| User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.0 |
| MIME-Version: | 1.0 |
| To: | "[ML] CygWin " <cygwin AT cygwin DOT com> |
| Subject: | ssh-agent variables available to any user process |
| OpenPGP: | id=C8F252FB |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
--------------040601010006070600050403
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Under FreeBSD, I launch ssh-agent in my .xsession script and its
environment is automatically inherited by every shell I then open in my
X11 session.
No such luck with Windows, but I found a way to propagate a environment
variable to any (future) user process after the user is already logged.
(or, at the very least...) Works for me.
Variables will be then available on any shell and program opened after
the attached script is executed.
(put it in "Startup" menu in order to execute it at logon time)
--
Lapo Luchini
lapo AT lapo DOT it (OpenPGP & X.509)
www.lapo.it (Jabber, ICQ, MSN)
--------------040601010006070600050403
Content-Type: application/x-javascript;
name="ssh-agent.js"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ssh-agent.js"
var sh = new ActiveXObject("WScript.Shell");
// execute ssh-agent and store its output
var agent = sh.Exec("C:\\cygwin\\bin\\ssh-agent.exe -s");
var out = agent.StdOut.ReadAll();
// parse output
var re = /([^=]+)=([^;]+); export \1;/g;
while ((arr = re.exec(out)) != null) {
// put the value in a volatile user variable
sh.Environment("VOLATILE")(arr[1]) = arr[2];
}
// SETX a dummy variable for the side effect of broadcasting a WM_SETTINGCHANGE
sh.Run("setx XYZZYX 1", 0, true);
// remove the user variable set by SETX
sh.Environment("USER")("XYZZYX") = "2"; // let it know the value changed
sh.Environment("USER").Remove("XYZZYX"); // ...else this would fail
--------------040601010006070600050403
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--------------040601010006070600050403--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |