This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Solution to using different usernames

My friend, Jeremy Bopp, let me know that if I use /etc/profile.d I could
still get updates for /etc/profile unlike when you edit it directly
(comment out USER="`id -un`"). I had to think of a way to change $USER
from a different file so I came up with:
# use Windows's USERNAME variable
export USER

rem strip trailing slash on "directory paths"
set "dp=%~dp0"
if "%dp:~-1%" equ "\" (
 set "dp=%dp:~0,-1%"
set "USERNAME=[username]"
set "HOME=%dp%\home\%USERNAME%"

I made the USER variable use the Windows variable USERNAME (standard
variable). From there I could change the USERNAME variable simply by
setting to what I like. I included the HOME variable in my code snippet.
I don't know if editting /etc/passwd will have the same behaviour as
editting /etc/profile and I don't know if /etc/passwd will change if I
take my Cygwin install to another computer. The main need for this hack
was that I use Cygwin from a USB and the default behaviour of Cygwin is
to use the currently logged in user which would mean I would have tons
of different profiles.

I thought this maybe useful for others to know so I decided to post
here. Also, if anybody has suggestions please let me and everybody know.

P.S. Still doesn't seem to work for SSH (ssh [user_to_use]@[machine]).
Maybe problem with SSH?

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]