X-Spam-Check-By: sourceware.org Message-ID: <85a409ca0605081850v188e2ae6n881b1cbb91f5d83a@mail.gmail.com> Date: Tue, 9 May 2006 13:50:49 +1200 From: "Paul Dorman" To: cygwin AT cygwin DOT com Subject: Environment variables in 1.5.19(0.150/4/2) 2006-01-20 13:28 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k491p6sd006164 Hi all, I'm having trouble with environment variables when running commands through ssh. I have applied this fix to my /etc/profile: # When initiating a Cygwin bash session via SSH, Cygwin only registers the environment variables # for the SYSTEM account, not for the individual user's account. if [ "$SSH_TTY" ]; then pushd . >/dev/null for __dir in \ /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\ Manager/Environment \ /proc/registry/HKEY_CURRENT_USER/Environment do cd "$__dir" for __var in * do __var=`echo $__var | tr '[a-z]' '[A-Z]'` test -z "${!__var}" && export $__var="`cat $__var`" >/dev/null 2>&1 done done unset __dir unset __var popd >/dev/null fi This works for standard ssh sessions, but not for commands run through ssh. The commands I'm running need access to the full environment variable list, which differs from machine to machine. Here's a summary of success and failure: 1. 'ssh user AT host' - environment variables okay with a normal ssh session. 2. 'ssh user AT host bash --login -i' - only some environment variables. 3. 'ssh user AT host mycmd - doesn't work due to missing environment variables. To illustrate, consider the difference between 1 and 3, here's the environment variables section of the output to cygcheck -sv: ( represents stuff I've taken out of this post) 1. 'ssh user AT host ' - then call cygcheck -sv: USER = 'deploy' PWD = '/home/deploy' CYGWIN = 'ntsec' HOME = '/home/deploy' MAKE_MODE = 'unix' HOMEPATH = '\cygwin\home\deploy' MANPATH = '/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man' SYBASE_SYSAM = 'SYSAM-3_0' HOSTNAME = '' TERM = 'cygwin' SHELL = '/bin/bash' PROCESSOR_IDENTIFIER = 'x86 Family 15 Model 2 Stepping 9, GenuineIntel' WINDIR = 'C:\WINNT' SSH_CLIENT = ' 41558 22' TEXDOCVIEW_txt = 'cygstart %s' TEXDOCVIEW_dvi = 'cygstart %s' OLDPWD = '/proc/registry/HKEY_CURRENT_USER/Environment' USERDOMAIN = ' ' SSH_TTY = '/dev/tty1' OS = 'Windows_NT' ALLUSERSPROFILE = 'C:\Documents and Settings\All Users' OS2LIBPATH = '%SystemRoot%\system32\os2\dll;' TEMP = '/cygdrive/c/WINNT/TEMP' COMMONPROGRAMFILES = 'C:\Program Files\Common Files' EASSHARE = 'C:\Servers\Sybase\Shared' USERNAME = 'deploy' JAGUAR_CLIENT_ROOT = 'C:\Servers\Sybase\EAServer' TEXDOCVIEW_pdf = 'cygstart %s' PROCESSOR_LEVEL = '15' MAIL = '/var/spool/mail/deploy' EQAENV = 'nzqa-uat1' SYSTEMDRIVE = 'C:' JAVA_HOME = 'C:\Servers\Sybase\Shared\j2sdk1.4.2_06\' JAGUAR = 'C:\Servers\Sybase\EAServer' TEXDOCVIEW_html = 'cygstart %s' USERPROFILE = 'C:\Documents and Settings\deploy' TZ = 'NZST-12NZDT-13,M10.1.0/2,M3.3.0/2' PS1 = '\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' LOGONSERVER = '\\' LM_LICENSE_FILE = 'C:\Program Files\Sybase\SYSAM-1_0\licenses\license.dat' PROCESSOR_ARCHITECTURE = 'x86' SHLVL = '1' PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' HOMEDRIVE = 'C:' CSAPROFILE = '' COMSPEC = 'C:\WINNT\system32\cmd.exe' LOGNAME = 'deploy' TMP = '/cygdrive/c/WINNT/TEMP' SYSTEMROOT = 'C:\WINNT' PRINTER = 'RICOH Aficio 2045 PS' CVS_RSH = '/bin/ssh' PROCESSOR_REVISION = '0209' SSH_CONNECTION = ' 41558 ' TEXDOCVIEW_ps = 'cygstart %s' INFOPATH = '/usr/local/info:/usr/share/info:/usr/info:' PROGRAMFILES = 'C:\Program Files' AVENGINE = 'C:\PROGRA~1\CA\SHARED~1\SCANEN~1' NUMBER_OF_PROCESSORS = '4' COMPUTERNAME = '' _ = '/usr/bin/cygcheck' POSIXLY_CORRECT = '1' 3. 'ssh user AT host cygcheck -sv': USER = 'deploy' PWD = '/home/deploy' CYGWIN = 'ntsec' HOME = '/home/deploy' HOMEPATH = '\cygwin\home\deploy' SHELL = '/bin/bash' PROCESSOR_IDENTIFIER = 'x86 Family 15 Model 2 Stepping 9, GenuineIntel' WINDIR = 'C:\WINNT' SSH_CLIENT = ' 41573 22' USERDOMAIN = '' OS = 'Windows_NT' ALLUSERSPROFILE = 'C:\Documents and Settings\All Users' TEMP = '/cygdrive/c/WINNT/TEMP' COMMONPROGRAMFILES = 'C:\Program Files\Common Files' USERNAME = 'deploy' PROCESSOR_LEVEL = '15' MAIL = '/var/spool/mail/deploy' SYSTEMDRIVE = 'C:' USERPROFILE = 'C:\Documents and Settings\deploy' LOGONSERVER = '\\' PROCESSOR_ARCHITECTURE = 'x86' SHLVL = '1' PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' HOMEDRIVE = 'C:' COMSPEC = 'C:\WINNT\system32\cmd.exe' LOGNAME = 'deploy' TMP = '/cygdrive/c/WINNT/TEMP' SYSTEMROOT = 'C:\WINNT' PROCESSOR_REVISION = '' SSH_CONNECTION = ' 41573 ' PROGRAMFILES = 'C:\Program Files' NUMBER_OF_PROCESSORS = '4' COMPUTERNAME = 'VULCAN' _ = '/usr/bin/cygcheck' POSIXLY_CORRECT = '1' This is a new problem since upgrading Cygwin. Is there a bug that needs to be fixed, or is this the correct way for Cygwin to function and I need to do something new to make it work? I tried the fix above as a separate script (with out the SSH_TTY requirement of course), but that didn't help either. Any help would be greatly appreciated. Regards, Paul -- 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/