Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serverVariables -- Script_name

Status
Not open for further replies.

qsac

Programmer
Jan 22, 2002
242
US
anyone have any idea why

request.servervariables("Script_name")

is returning path and script

ex file test.asp is in c:\test

if I do

dim scriptName
scriptName=request.servervariables("Script_name")
response.write scriptName

It returns /test/test.asp where i am just looking for test.asp.

Any Clues? I can write code to manipulate the variable to return the result i want, but i just want to see if there is a way to just get the script name, in this case it would be test.asp

thanks in advance
 
for what you're looking for i'd use a combination of instr and request.servervariables("url")


[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Code:
dim ScriptArray
ScriptArray = Split(request.servervariables("Script_name"),"/")
response.write ScriptArray(ubound(ScriptArray))



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
If you use instrRev(request.servervariables("url", "/") you can get the position of the last / and do a right() on the url to get the file name.
 
SCRIPT_NAME always returns the virtual path for thecurrent script, basically everything to the right of the minus any querystring variables.
As mbiro pointed out, an InStrRev will solve thisif you only want the actual filename (or the Split from Chris) instead of the virtual path.

-T


barcode_1.gif
 
And just to be redundant, as far as the server is concerned, the name of your script is "/test/test.asp". As far as it's concerned there might well be another script called "test.asp" in the web root, so it has to differentiate.
Code:
Right(string, Len(string) - InStrRev(string, "/"))
should do the trick, even if there's no "/" in the string (though someone correct me if necessary, I just woke up).
 
No, I think it would work. InStrRev would return 0, so it would do a Right on the full length...er, I think...ok, someone paste that thing into a sample asp file and give us an answer, I'm going to play a game :p

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top