Mail Archives: cygwin/2006/05/08/21:51:13
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:
(<removed> 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 = '<removed>'
TERM = 'cygwin'
SHELL = '/bin/bash'
PROCESSOR_IDENTIFIER = 'x86 Family 15 Model 2 Stepping 9, GenuineIntel'
WINDIR = 'C:\WINNT'
SSH_CLIENT = '<removed> 41558 22'
TEXDOCVIEW_txt = 'cygstart %s'
TEXDOCVIEW_dvi = 'cygstart %s'
OLDPWD = '/proc/registry/HKEY_CURRENT_USER/Environment'
USERDOMAIN = ' <removed>'
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 = '\\<removed>'
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 = '<removed>'
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 = '<removed> 41558 <removed>'
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 = '<removed>'
_ = '/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 = '<removed> 41573 22'
USERDOMAIN = '<removed>'
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 = '\\<removed>'
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 = '<removed>'
SSH_CONNECTION = '<removed> 41573 <removed>'
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/
- Raw text -