Get username from os in a variable. - Forum

Forum Navigation
You need to log in to create posts and topics.

Get username from os in a variable.

Hi all,

I need to get the username from OS and store in a variable at the very first moment the app starts. But i can't find how to do it, javascript can do this ? i had read that from client side is impossible. Another way i figured was to create a python funtion executed from an form action and get the html response containing the username, but i can't find how to execute this without to press a form boton.

 

Regards,

Sam.

Hi @lesanch

You can use a hidden Form and then FormSubmit or ClickObject commands to send the form using code.
Another option is using FileToVar sending URL parameters to the Python script.
Regards.

Hi,

On page-enter i have:

FileToVar "http://localhost:8000/cgi-bin/modulos/get_user.py" [Data]

but nothing happens, i don't know if i'm missing something. The var DATA it's empty.

The .py contents is as simple as this:

import cgi, cgitb
import getpass

print ("Access-Control-Allow-Origin: *\r\n\r\n")

# Create instance of FieldStorage
form = cgi.FieldStorage()

userso=(getpass.getuser())
print (userso)

 

Using form it's not working neither after set ACTION field with .py script.

Reading the http.server logs the execution is finish OK.

Regards,

Sam

@lesanch

what is your webserver ?

a python integrated web server very tiny. but i installed yestarday LARAGON, so i going to test with that. The others .py scripts return ok, the only difference is that this script makes an print only, the others return values from funtions and then print.

Regards,

Sam

 

The [Returnstatus] of the execution is -1

>>>>> SetVar [ReturnStatus] [Status]

but i can't see the error, it's not Displayed.

>>>>> SetObjectHTML "Container1" "[Data]" -----> this remains null

Regards,
Sam

problem resolved, i can't be such as stup... :-DD.

Sorry, web server problems :-)

Regards,

Sam