Solved

VBScript Runtime error occuring on Linux server with Sun Java System Active Server Pages installed.

Posted on 2008-06-26
8
392 Views
Last Modified: 2013-11-21
I created a new web site in asp, using VB Script to produce some dynamic elements. It was created ona computer running ISS. Once it was migrated to a server running Linux, with Sun Java System Active Server Pages loaded on it to run the asp pages, it started throwing an error (see below.)

*********
Error Type:
Sun ONE ASP VBScript runtime (0x800A0009) Subscript out of range /new-web/web-site/index.asp, line 150
***********

I have attached the code of the funtion that is causing the error, which occurs at the line:
file_name = parts(0)
I can see no reason why this error is happening, and need help.

Thanks

Lee
<%
			'More complex function that requires use of server functions and means any image can be dropped into
			'the RandomImage folder. It must be a gif or jpg, although a parameter can be added into the function
			'to deal with other image types.
 
			Function RandomImage(ImagesFolderPath, ImageFileTypes, ImageDescription)
 
			'Declare variables
			Dim CompleteImagesFolderPath
			Dim FileSystemObject
			Dim ImageFolder
			Dim Files
			Dim i
			Dim ImageFiles
			Dim File
			Dim FileName
			Dim FileExtension
			Dim RandomNumber
			
			'Find the complete path to image folder by using Server.MapPath
			CompleteImagesFolderPath = Server.MapPath(ImagesFolderPath)
			
			'Create an instance of the FileSystemObject which allows ASP to
			'access the file system 
			Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
			
			'Check that the folder containing the images exists
			If Not FileSystemObject.FolderExists(CompleteImagesFolderPath) Then
			RandomImage = "Error 0: Cannot find requested folder"
			Set FileSystemObject = nothing
			Exit Function
			End If
			
			'Get the folder containing the images
			Set ImageFolder = FileSystemObject.GetFolder(CompleteImagesFolderPath)
			
			'Get a list of all the files within the images folder
			Set Files = ImageFolder.Files
			
			'Use a dictionary object to temporarily store the image file names
			i = 1
			Set ImageFiles = Server.CreateObject("Scripting.Dictionary")
			
			'Loop through the list of files within the images folder.
			'If the file has a file extension that is in the list of
			'file types specified in the ImageFileTypes function parameter,
			'then add the file name to the ImageFiles dictionary object
			For Each File in Files
			
			FileName = File.Name
			FileExtension = Right(FileName, Len(FileName) - (InStrRev(FileName, ".")))
			
			If InStr(1,ImageFileTypes,FileExtension,vbTextCompare) > 0 then
			ImageFiles.Add i, FileName
			i = i + 1
			End If
			
			Next
			
			'Destroy objects that are no longer required
			Set ImageFolder = nothing
			Set Files = nothing
			Set FileSystemObject = nothing
			
			'Initialise the random number generator
			Randomize
			
			' Check that image file(s) have been found
			If ImageFiles.Count = 0 Then
			RandomImage = "Error 1: Requested folder does not contain any image files"
			Exit Function
			End If
			
			'Generate a random number between 1 and the number of image files
			RandomNumber = Int((ImageFiles.Count) * Rnd + 1)
			
			'Return a hyperlink to a random image file
			RandomImage = "<img src=" & Chr(34) & ImagesFolderPath & ImageFiles.Item(RandomNumber) & Chr(34) & " alt=" & Chr(34) & ImageDescription & Chr(34) & "width='150px' height='150px'>"
			
			'This function will strip out the filename and use it as a Caption for the picture
			Dim Caption
			Caption = ImageFiles.Item(RandomNumber)
			parts = split(Caption, ".")
			file_name = parts(0)
			ext = parts(1)
			Caption = "<div class='caption'>" & file_name & "</div>"
			Response.Write(Caption)
 
			Set ImageFiles = nothing
			
			End Function
			
			'Call the function and write to the screen, passing in the arguments for the function.
			Response.Write RandomImage("RandomImage/", "gif jpg", "Plasmocom")
			
			
 
			'The function has three arguments. The first (ImagesFolderPath) is 
			'the name of the folder containing the images in this case Random Image, 
			'and it should be a sub-folder of the folder that contains the ASP document. 
			'The second argument should be a string containing a list of file types to use 
			'as images (e.g. jpeg, jpg, gif). Finally, the last argument is a 
			'short sentence to describe your image (which is used as the images ALT tag).
			%>

Open in new window

0
Comment
Question by:wattie187
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 15

Accepted Solution

by:
dosth earned 500 total points
ID: 21873377
it means after split for . no data is come there as a result

after split check for ubound
parts = split(Caption, ".")
if ubound(parts)>=1 then

                        file_name = parts(0)
                        ext = parts(1)
end if
0
 
LVL 13

Expert Comment

by:jmundsack
ID: 21873744
dosth is correct -- but maybe the problem is deeper than checking for whether the string contains a dot.  Is there something about Linux / Apache that would cause file names not to return file extensions?  Or something about the implementation of FileSystemObject on the Linus OS?  You may want to run some simple tests using FileSystemObject and see if there is something different in the implementation of how file names are being presented in the new environment.
0
 

Author Comment

by:wattie187
ID: 21873970
I have sent the new file to the customer and am awaiting a response. But you may be right in your thinking of the FileSystemObject but I won't be able to tell until they email me back.

Thanks
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 15

Expert Comment

by:dosth
ID: 21874021
sounds good
0
 

Author Comment

by:wattie187
ID: 21897663
Can't get a meeting with the customer till Wednesday, but I think dosth could be getting the points as he seems to have solved the original error. Another question might be posted to see if the root problem gets sorted, if I can't work round it myself.

Cheers
0
 
LVL 15

Expert Comment

by:dosth
ID: 21897689
Thanks Watt
0
 

Author Closing Comment

by:wattie187
ID: 31470918
Thanks for the help, this solved my problem although it did uncover a bigger one :) Got it all sorted in the end. Thanks again.
0
 
LVL 15

Expert Comment

by:dosth
ID: 21923556
Thanks again for the points
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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