Solved

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

Posted on 2008-06-26
8
389 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
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my Splunk Web URL not working? 2 66
Server Timeout with Loop 6 45
Compile Error 7 51
i have to take the screenshot of command prompt? how to do this? 1 37
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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