0

My computer's operating system is Windows. I use "my_lastname.myfirst_name" login to access to my windows user session. For my new Django python project, I'm using ubuntu OS in a virtual machine. I'm trying to get my login windows from the virtual machine. To do this i used these examples:

>> import pwd
>> user_name = pwd.getpwuid( os.getuid() )[ 0 ]

>> import socket
>> user_name = socket.gethostname()

The above blocs of code give me the localhost name of the ubuntu machine.

How can i access to windows session username from the ubuntu guest OS with python ?

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
Sam
  • 523
  • 2
  • 5
  • 14
  • Are you using VirtualBox? Vagrant? Docker? – cwallenpoole Feb 16 '17 at 15:40
  • yes, i'm using VirtualBox and Vagrant – Sam Feb 16 '17 at 15:41
  • Don't have time to write a full answer, but you should look into setting the environment variable through the Vagrant file http://stackoverflow.com/questions/19648088/pass-environment-variables-to-vagrant-shell-provisioner. If that doesn't work, you could set it through VirtualBox https://forums.virtualbox.org/viewtopic.php?f=3&t=73154. – cwallenpoole Feb 16 '17 at 15:46

0 Answers0