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
Solved

Stop running script

Posted on 2001-06-08
14
278 Views
Last Modified: 2007-12-19
Hi,
I have an ASP search script that runs for too long.  Is there any way to stop the script once it has started?  I do not have access to change the server.scripttimeout default value and 90 seconds is way to long.  I have tried a stop button that would spark a response.end if statement but once the script is started it will not even let you get back to the page.  
Thanks
0
Comment
Question by:theywanttheworld
  • 2
  • 2
  • 2
  • +6
14 Comments
 

Accepted Solution

by:
HabBoy earned 200 total points
ID: 6168934
Not sure if this is what you are looking for but you could put a timed loop in and when your condition is met you would do this:

Response.Clear
Response.End
0
 

Expert Comment

by:dlillibridge
ID: 6169228
Call the Server.ScriptTimeout = NumSeconds
command and set the script timeout just for that specific page.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6169392
No script should take 90 seconds to run.  period.  If it really takes this long for a script to load and run, it's time to rebuild the scripts.

What is this code doing?  Are you taking advantages of subs and Functions calls?  You can always put an Exit in your code to stop functions and sub commands;
The Exit statement allows you to exit from inside a block of code such as a conditional statement (Do ...Loop, For ... Next, For Each ... Next) or a procedure (Function, Sub) before it would normally be completed.
 

 
This allows you to exit from inside a Do Until ... Loop.
 
Code:
<% Exit Do %>
 

 
This allows you to exit from inside a Do While ... Loop.
 
Code:
<% Exit Do %>
 
This allows you to exit from inside a For ... Next.
 
Code:
<% Exit For %>
 
This allows you to exit from inside a For Each ... Next.
 
Code:
<% Exit For %>
 
This allows you to exit from inside a Function.
 
Code:
<% Exit Function %>
 
This allows you to exit from inside a Sub.
 
Code:
<% Exit Sub %>

... post the script sommewhere so we can see if it can be streamlined.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 2

Expert Comment

by:_marko_
ID: 6169724
mqfranz:
> No script should take 90 seconds to run.  period.

I beg to differ. I had to write write a search engine for some AutoCAD files a year back. The engine was not a big deal, but the process of updating the database was. When updating it would have to browse through two directories with tens of thousands of files each, check the file names with all those existing in the database. If the file had been deleted then it must be deleted from the database and if a file had been added to the directory then the reference must also be added to the database. I used 16 000 files to simulate the process.

At first I tried to delete all the entries from the database and to add the whole directory every time. It was the fastest way, but it bloated the database and after a few testruns it was >30 Mb in size. That solution was no good so I hit my head against the wall a couple of times and finally I had a working algorithm. At first the process took approximately 5 hours but after 'some' streamlining I got it down to 3 minutes on a regular PC without bloating the database. I was satisfied :-)

Anyway, the point of this story was, that there are scripts which have execution times past 90 seconds.


As for the question at hand,

theywanttheworld:
I don't really have any suggestions, but I'd say that if dlillibridge's answer isn't right you should explain the problem a little closer.

-Marko
0
 
LVL 5

Expert Comment

by:dgorin
ID: 6169772
I don't quite understand, do you want to interrupt the correctly running script so it doesn't finish, or does the script get off in left field somewhere?

I'm with mqfranz, any asp script that takes 90+ seconds to run normally is not acceptable.  Such a script will time out without completing on most web servers.  Some kind of architectural change should be made.

If there is a problem with the script that makes it run too long, post the code here & maybe someone can see the problem.

0
 
LVL 7

Expert Comment

by:weesiong
ID: 6170261
HadBoy is correct, using Response.Clear, Response.End :o

Regards,
Wee Siong
0
 
LVL 5

Expert Comment

by:Kelmen
ID: 6175558
You should elaborate more on "Why you want to Stop the scripting once it's executed"? Is it's because you just testing some something?
0
 

Expert Comment

by:melio
ID: 6176024
theywanttheworld,

i got this from the msdn library:

End
The End method causes the Web server to stop processing the script and return the current result. The remaining contents of the file are not processed.

Syntax
Response.End

Remarks
If Response.Buffer has been set to TRUE, calling Response.End will flush the buffer. If you do not want output returned to the user, you should call Response.Clear first.

<%
  Response.Clear
  Response.End
%>

i still encourage having the code posted here. thanks!
0
 

Expert Comment

by:melio
ID: 6176026
theywanttheworld,

i got this from the msdn library which is very similar to habboy's comment/suggestion:

End
The End method causes the Web server to stop processing the script and return the current result. The remaining contents of the file are not processed.

Syntax
Response.End

Remarks
If Response.Buffer has been set to TRUE, calling Response.End will flush the buffer. If you do not want output returned to the user, you should call Response.Clear first.

<%
  Response.Clear
  Response.End
%>

i still encourage having the code posted here. thanks!
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6177268
melio, lets see...

HabBoy covered the Clear/End method, and I covered the End method.

What have you got to contribute that hasn't already been covered?
0
 

Author Comment

by:theywanttheworld
ID: 6178045
Thanks, I used second(now) before and and after a certain section of code and then and if statement set for 3 seconds to response.end.  

The script is a search engine script.  The reason that it takes so long to run is that is that there is a ton of folders and sub folders to go through with some large files.  I think that it got really bogged down when it hit this one particular folder.  Not anymore.

Thanks HabBoy and everyone else who helped.
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6179710
theywanttheworld,

Why dont try using Server.ScriptTimeOut()
<%
Server.ScriptTimeOut = 10 '10 second
.
.
%>

Regards,
Wee Siong
0
 

Author Comment

by:theywanttheworld
ID: 6181273
The default server timeout is 90 seconds.  You can set in the script for any time that is above the setting on the server.  If you try to set it in the script like Server.ScriptTimeOut = 10 it will not work unless the setting on the server is 10 or less.  I don't have access to the server to manually lower the timeout value.  I found this posted numerous places on the internet.

Thanks to all.
0
 
LVL 5

Expert Comment

by:Kelmen
ID: 6217759
Instead of forcefully End the program execution, why don't you set a counter for the searching limit?

Like do a counter for numbers of file searched or the seconds elapse...

Below's a sample, if you interested you may need refine the codes.

Dim sngStart

sngStart = Timer()

Do While (blnContinue)
   ...searching...
   blnContinue = CBool( (Timer() - sngStart) <= 9999 )
Loop

HTH.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dreamweaver server behavior gone 6 145
Multiflying 2 Input Text On a Table 7 31
innerHTML 7 34
Diminish Pop-up  in 3 seconds 7 45
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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