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

Posted on 2008-06-26
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.



			'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




			'Destroy objects that are no longer required

			Set ImageFolder = nothing

			Set Files = nothing

			Set FileSystemObject = nothing


			'Initialise the random number generator



			' 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>"


			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

Question by:wattie187
  • 4
  • 3
LVL 15

Accepted Solution

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
LVL 13

Expert Comment

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.

Author Comment

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.

LVL 15

Expert Comment

ID: 21874021
sounds good
Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.


Author Comment

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.

LVL 15

Expert Comment

ID: 21897689
Thanks Watt

Author Closing Comment

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.
LVL 15

Expert Comment

ID: 21923556
Thanks again for the points

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 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

14 Experts available now in Live!

Get 1:1 Help Now