Solved

get environment variable in javascript web code

Posted on 2004-04-20
7
810 Views
Last Modified: 2007-12-19
Hello,

does anyone know how to read an environment variable into a javascript running in a html page?

I would like to take appropriate action in the web page based on a particular environment variable....

thx,
Shaun
0
Comment
Question by:sbradley2002
  • 3
  • 2
7 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875725
Hi sbradley2002,

Local (workstation) environment variable, or one defined on the (Windows?) web server?

BFN,

fp.
0
 

Author Comment

by:sbradley2002
ID: 10875732
fanpages,

sorry didn't say,
I want it to read the variable from the client machine.
I should say that this web page is only being run as a web desktop on windows xp pro machines in my organisation, not actually being published anywhere

thx,
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875842
Hi,

I'm fairly certain that you cannot do this directly in HTML/Javascript alone.

You would need a scripting language such as Perl, CGI, PHP, VBScript etc on your client machine, or a Java applet.

Could you not use cookies instead?  And during installation of the client machines set the cookies to the initial values as defined in your DOS environment variables?

Or, maybe you could invoke the .htm(l) page with query parameters (?path=<...>&comspec=<...>) set by an external process (e.g. a Visual Basic .exe) that could read the environment variables in advance.

Sorry...

BFN,

fp.
0
 

Author Comment

by:sbradley2002
ID: 10875880
whatever works....
Would u know how to set up these cookies - or where I can find this info?
Can they be setup each time a user logs in on the machine?
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 100 total points
ID: 10876056
The cookies would need to be set by a server-based process, that yes, could be invoked during log-on to the machine (if the machines are connected to a central server).

The server process would be called, query the environment variables of the connected workstation (maybe just a simply "set" command to a temporary file that is read on the server and cookie creation directly based on the contents of the file), and return to the log-in procedure.

Your client-side javascript should then query the cookies & act accordingly.

I don't know of any URLs off-hand.

Maybe just "google" for them?

BFN,

fp.

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now