HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 29th, 2002, 01:16 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
execute a .bat from .asp

Originally posted by : shiju (webshiju@hotmail.com)i'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
  #2  
Old February 6th, 2002, 12:35 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Originally posted by : Dave Wood (obsidian@panix.com)You know, Microsoft does an amazing amount of work to document their products. Unfortunately, all of it is really _bad_ work. Their documentation is the most disorganized and ridiculous I've seen for any commercial software (and that includes Oracle!) and it's impossible to find out anything really useful - especially about simple, basic stuff like this.I did manage this today; it wasn't easy. 1) Get the latest version of the scripting host and install it (5.6 as of this writing). http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml2) Use Exec instead of Run. Henceim Shell Set Shell = Server.CreateObject("WScript.Shell") Dim sexecSet sexec = Shell.Exec("c: estupdate.bat")3) Make sure you read out the stdout and stderr streams. Things don't seem to happen unless you do that.Dim soutsout = sexec.stdout.readAllDim serrserr = sexec.stderr.readAll' (You might need to do this repetitively, though I didn't) ' I take a look at it in my page here:Response.write ""Response.write "ReadAll: " & resultResponse.write "stderr: " & serr4) You're still executing asyncronously. You'll need to do a busy wait loop for your script to finish - since there's no accessible sleep function in the ASP context and no "finished" event on exec. ROTFLMFAO. Go ahead and get yourself a delay timer activeX control. Fortunately someone wrote one and you can download the DLL:http://www.aspalliance.com/stevesmith/articles/sleeptimer.aspOf course, the poor bastard doesn't tell you how to actually USE it...regsvr32 c:whereveryouput imer.dllAnd thenDim timerset timer = Server.CreateObject("Timer.Sleep")Do While sexec.Status 1 timer.DoSleep(100)LoopOnce sexec.Status becomes 1, execution is complete, and sexec.ExitCode becomes valid.****ing brilliant, eh? Now, what the hell are you doing writing ASP code anyway? Let me give you a hint: you can do all this with one line of PHP code, and you won't need to get 0wned by Nimda before you can install all your IIS patches, either. Take my advice, take your Win2K CD, go to the microwave, and give it about 2 minutes on high. Then go buy RedHat. You can thank me later.------------shiju at 1/29/2002 11:16:43 AMi'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
  #3  
Old February 6th, 2002, 12:51 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Originally posted by : Dave Wood (obsidian@panix.com)Oh yeah... did eventually manage to get Run to work also, so it's a bit simpler if you don't need access to your program's output or input:dim exitcodeexitcode = script.run("your command",10,true) The last arg is true to wait until execution is complete, and get the proper exit code...------------Dave Wood at 2/5/2002 10:35:13 PMYou know, Microsoft does an amazing amount of work to document their products. Unfortunately, all of it is really _bad_ work. Their documentation is the most disorganized and ridiculous I've seen for any commercial software (and that includes Oracle!) and it's impossible to find out anything really useful - especially about simple, basic stuff like this.I did manage this today; it wasn't easy. 1) Get the latest version of the scripting host and install it (5.6 as of this writing). http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml2) Use Exec instead of Run. Henceim Shell Set Shell = Server.CreateObject("WScript.Shell") Dim sexecSet sexec = Shell.Exec("c: estupdate.bat")3) Make sure you read out the stdout and stderr streams. Things don't seem to happen unless you do that.Dim soutsout = sexec.stdout.readAllDim serrserr = sexec.stderr.readAll' (You might need to do this repetitively, though I didn't) ' I take a look at it in my page here:Response.write ""Response.write "ReadAll: " & resultResponse.write "stderr: " & serr4) You're still executing asyncronously. You'll need to do a busy wait loop for your script to finish - since there's no accessible sleep function in the ASP context and no "finished" event on exec. ROTFLMFAO. Go ahead and get yourself a delay timer activeX control. Fortunately someone wrote one and you can download the DLL:http://www.aspalliance.com/stevesmith/articles/sleeptimer.aspOf course, the poor bastard doesn't tell you how to actually USE it...regsvr32 c:whereveryouput imer.dllAnd thenDim timerset timer = Server.CreateObject("Timer.Sleep")Do While sexec.Status 1 timer.DoSleep(100)LoopOnce sexec.Status becomes 1, execution is complete, and sexec.ExitCode becomes valid.****ing brilliant, eh? Now, what the hell are you doing writing ASP code anyway? Let me give you a hint: you can do all this with one line of PHP code, and you won't need to get 0wned by Nimda before you can install all your IIS patches, either. Take my advice, take your Win2K CD, go to the microwave, and give it about 2 minutes on high. Then go buy RedHat. You can thank me later.------------shiju at 1/29/2002 11:16:43 AMi'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
  #4  
Old February 6th, 2002, 07:02 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Originally posted by : Shiju Rajan (webshiju@hotmail.com)Hi Dave, Thanks for your help..It is very useful information you wrote here...You know my WScript.Run start working after i install the asp.net on IIS ... i really don't know how it is start working...i'm going to try your code now.... and i'll try that timer control also.becuase i need to make sure that the .bat file is finishing successfully and the other users are not distrupting the execution... i'm planning to have an application variable initialized in asp for preventing the simultanious execution of .bat... what you suggest on that?you may write an article regarding same topic and publish in some site then that would be really helpful for the other programmers..I really appreciate your help..Thanks againGod bless! ------------Dave Wood at 2/5/2002 10:51:01 PMOh yeah... did eventually manage to get Run to work also, so it's a bit simpler if you don't need access to your program's output or input:dim exitcodeexitcode = script.run("your command",10,true) The last arg is true to wait until execution is complete, and get the proper exit code...------------Dave Wood at 2/5/2002 10:35:13 PMYou know, Microsoft does an amazing amount of work to document their products. Unfortunately, all of it is really _bad_ work. Their documentation is the most disorganized and ridiculous I've seen for any commercial software (and that includes Oracle!) and it's impossible to find out anything really useful - especially about simple, basic stuff like this.I did manage this today; it wasn't easy. 1) Get the latest version of the scripting host and install it (5.6 as of this writing). http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml2) Use Exec instead of Run. Henceim Shell Set Shell = Server.CreateObject("WScript.Shell") Dim sexecSet sexec = Shell.Exec("c: estupdate.bat")3) Make sure you read out the stdout and stderr streams. Things don't seem to happen unless you do that.Dim soutsout = sexec.stdout.readAllDim serrserr = sexec.stderr.readAll' (You might need to do this repetitively, though I didn't) ' I take a look at it in my page here:Response.write ""Response.write "ReadAll: " & resultResponse.write "stderr: " & serr4) You're still executing asyncronously. You'll need to do a busy wait loop for your script to finish - since there's no accessible sleep function in the ASP context and no "finished" event on exec. ROTFLMFAO. Go ahead and get yourself a delay timer activeX control. Fortunately someone wrote one and you can download the DLL:http://www.aspalliance.com/stevesmith/articles/sleeptimer.aspOf course, the poor bastard doesn't tell you how to actually USE it...regsvr32 c:whereveryouput imer.dllAnd thenDim timerset timer = Server.CreateObject("Timer.Sleep")Do While sexec.Status 1 timer.DoSleep(100)LoopOnce sexec.Status becomes 1, execution is complete, and sexec.ExitCode becomes valid.****ing brilliant, eh? Now, what the hell are you doing writing ASP code anyway? Let me give you a hint: you can do all this with one line of PHP code, and you won't need to get 0wned by Nimda before you can install all your IIS patches, either. Take my advice, take your Win2K CD, go to the microwave, and give it about 2 minutes on high. Then go buy RedHat. You can thank me later.------------shiju at 1/29/2002 11:16:43 AMi'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
  #5  
Old February 6th, 2002, 11:32 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Originally posted by : David Wood (obsidian@panix.com)"You know my WScript.Run start working after i install the asp.net on IIS ... i really don't know how it is start working..."I assume the asp.net install upgrades your scripting host. "i'm planning to have an application variable initialized in asp for preventing the simultanious execution of .bat... what you suggest on that?"Good idea. I don't know whether or not you'll need to lock the Application object just to set/check your "bat in use" field in order to prevent a race. You might. In which case I hope you have nothing else already setting application fields elsewhere, because you can only lock the whole thing at once. Heh.------------Shiju Rajan at 2/6/2002 5:02:25 AMHi Dave, Thanks for your help..It is very useful information you wrote here...You know my WScript.Run start working after i install the asp.net on IIS ... i really don't know how it is start working...i'm going to try your code now.... and i'll try that timer control also.becuase i need to make sure that the .bat file is finishing successfully and the other users are not distrupting the execution... i'm planning to have an application variable initialized in asp for preventing the simultanious execution of .bat... what you suggest on that?you may write an article regarding same topic and publish in some site then that would be really helpful for the other programmers..I really appreciate your help..Thanks againGod bless! ------------Dave Wood at 2/5/2002 10:51:01 PMOh yeah... did eventually manage to get Run to work also, so it's a bit simpler if you don't need access to your program's output or input:dim exitcodeexitcode = script.run("your command",10,true) The last arg is true to wait until execution is complete, and get the proper exit code...------------Dave Wood at 2/5/2002 10:35:13 PMYou know, Microsoft does an amazing amount of work to document their products. Unfortunately, all of it is really _bad_ work. Their documentation is the most disorganized and ridiculous I've seen for any commercial software (and that includes Oracle!) and it's impossible to find out anything really useful - especially about simple, basic stuff like this.I did manage this today; it wasn't easy. 1) Get the latest version of the scripting host and install it (5.6 as of this writing). http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml2) Use Exec instead of Run. Henceim Shell Set Shell = Server.CreateObject("WScript.Shell") Dim sexecSet sexec = Shell.Exec("c: estupdate.bat")3) Make sure you read out the stdout and stderr streams. Things don't seem to happen unless you do that.Dim soutsout = sexec.stdout.readAllDim serrserr = sexec.stderr.readAll' (You might need to do this repetitively, though I didn't) ' I take a look at it in my page here:Response.write ""Response.write "ReadAll: " & resultResponse.write "stderr: " & serr4) You're still executing asyncronously. You'll need to do a busy wait loop for your script to finish - since there's no accessible sleep function in the ASP context and no "finished" event on exec. ROTFLMFAO. Go ahead and get yourself a delay timer activeX control. Fortunately someone wrote one and you can download the DLL:http://www.aspalliance.com/stevesmith/articles/sleeptimer.aspOf course, the poor bastard doesn't tell you how to actually USE it...regsvr32 c:whereveryouput imer.dllAnd thenDim timerset timer = Server.CreateObject("Timer.Sleep")Do While sexec.Status 1 timer.DoSleep(100)LoopOnce sexec.Status becomes 1, execution is complete, and sexec.ExitCode becomes valid.****ing brilliant, eh? Now, what the hell are you doing writing ASP code anyway? Let me give you a hint: you can do all this with one line of PHP code, and you won't need to get 0wned by Nimda before you can install all your IIS patches, either. Take my advice, take your Win2K CD, go to the microwave, and give it about 2 minutes on high. Then go buy RedHat. You can thank me later.------------shiju at 1/29/2002 11:16:43 AMi'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
  #6  
Old February 6th, 2002, 01:26 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Originally posted by : Shiju (webshiju@hotmail.com)Yes David,i'm planning to do the same action.i'll lock the application object before .bat execution and after the use i'll unlock the variable.so that action should work fine.Thanks for the help..------------David Wood at 2/6/2002 9:32:42 AM"You know my WScript.Run start working after i install the asp.net on IIS ... i really don't know how it is start working..."I assume the asp.net install upgrades your scripting host. "i'm planning to have an application variable initialized in asp for preventing the simultanious execution of .bat... what you suggest on that?"Good idea. I don't know whether or not you'll need to lock the Application object just to set/check your "bat in use" field in order to prevent a race. You might. In which case I hope you have nothing else already setting application fields elsewhere, because you can only lock the whole thing at once. Heh.------------Shiju Rajan at 2/6/2002 5:02:25 AMHi Dave, Thanks for your help..It is very useful information you wrote here...You know my WScript.Run start working after i install the asp.net on IIS ... i really don't know how it is start working...i'm going to try your code now.... and i'll try that timer control also.becuase i need to make sure that the .bat file is finishing successfully and the other users are not distrupting the execution... i'm planning to have an application variable initialized in asp for preventing the simultanious execution of .bat... what you suggest on that?you may write an article regarding same topic and publish in some site then that would be really helpful for the other programmers..I really appreciate your help..Thanks againGod bless! ------------Dave Wood at 2/5/2002 10:51:01 PMOh yeah... did eventually manage to get Run to work also, so it's a bit simpler if you don't need access to your program's output or input:dim exitcodeexitcode = script.run("your command",10,true) The last arg is true to wait until execution is complete, and get the proper exit code...------------Dave Wood at 2/5/2002 10:35:13 PMYou know, Microsoft does an amazing amount of work to document their products. Unfortunately, all of it is really _bad_ work. Their documentation is the most disorganized and ridiculous I've seen for any commercial software (and that includes Oracle!) and it's impossible to find out anything really useful - especially about simple, basic stuff like this.I did manage this today; it wasn't easy. 1) Get the latest version of the scripting host and install it (5.6 as of this writing). http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml2) Use Exec instead of Run. Henceim Shell Set Shell = Server.CreateObject("WScript.Shell") Dim sexecSet sexec = Shell.Exec("c: estupdate.bat")3) Make sure you read out the stdout and stderr streams. Things don't seem to happen unless you do that.Dim soutsout = sexec.stdout.readAllDim serrserr = sexec.stderr.readAll' (You might need to do this repetitively, though I didn't) ' I take a look at it in my page here:Response.write ""Response.write "ReadAll: " & resultResponse.write "stderr: " & serr4) You're still executing asyncronously. You'll need to do a busy wait loop for your script to finish - since there's no accessible sleep function in the ASP context and no "finished" event on exec. ROTFLMFAO. Go ahead and get yourself a delay timer activeX control. Fortunately someone wrote one and you can download the DLL:http://www.aspalliance.com/stevesmith/articles/sleeptimer.aspOf course, the poor bastard doesn't tell you how to actually USE it...regsvr32 c:whereveryouput imer.dllAnd thenDim timerset timer = Server.CreateObject("Timer.Sleep")Do While sexec.Status 1 timer.DoSleep(100)LoopOnce sexec.Status becomes 1, execution is complete, and sexec.ExitCode becomes valid.****ing brilliant, eh? Now, what the hell are you doing writing ASP code anyway? Let me give you a hint: you can do all this with one line of PHP code, and you won't need to get 0wned by Nimda before you can install all your IIS patches, either. Take my advice, take your Win2K CD, go to the microwave, and give it about 2 minutes on high. Then go buy RedHat. You can thank me later.------------shiju at 1/29/2002 11:16:43 AMi'm trying to execute a .bat file from .asp file on Windows2000 system.i tried the following code:when i use command line above .bat is working perfectly fine. but when i run above .asp it is giving "not working" message..i tried cahnging the file permission still no luck. can u tell me what is should do executing the .bat from .asp..thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > execute a .bat from .asp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway