p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_components thread: Execute server application from an ASP page


Message #1 by "Aneeqah AneeqahVahed" <aneeqahv@u...> on Mon, 23 Dec 2002 14:22:03 +0200
Hi there

Can anyone please HELP!! 

I am trying to run a Batch file from an ASP page which has to remotely 
execute a program 

within SAS. The client clicks a button that should tell the server to 
run the Batch file, 

which starts SAS on the server side which then executes my program and 
saves the results on 

to the server harddrive. The client is then able to view the tresults 
from the web. I have 

used both ASPExec and WScript and both of 
these work in the sense 

that it starts the batch file on the server. The problem is that I 
cannot see the process 

running on the server, ie: the batch file uses "cmd" and "SAS.exe" but 
neither of these 

programs are visible. They do however run as hidden process' and I 
know this because they 

appear in the process table. I thought, to see the process I should 
change the settings for 

WWWPublishing to "set active with desktop" but this was not the case. 
The thing is, the 

output file is never created and neither cmd or SAS can be terminated. 
I know that the batch 

file works because it runs perfectly as a stand alone, ie:when not 
called from the web page. 


DO u have any idea how to solve this ? 

Kind regards 


Aneeqah Vahed
University of the Western Cape
COE LAB
Tel (021) 959 300
Message #2 by "aneeqah vahed" <aneeqahv@u...> on Mon, 23 Dec 2002 13:39:07
I used the following code to try and execute the batch file

<HTML><HEAD>
<Script Language="VBScript" runat="server">
<!--
sub Tester()
set wshShell = Server.CreateObject("WScript.Shell")
wshShell.Run "cmd C:\\Inetpub\wwwroot\CourseEval\BATCHtester.bat" ,1,false
set wshShell=Nothing 
End Sub 
-->
</Script>
</head>
<BODY><INPUT id=button1 name=button1 type=button value=Button 
onclick= "Tester()"> 
Message #3 by "SEAK, Teng-Fong" <tfseak@f...> on Mon, 23 Dec 2002 17:09:19 +0100
	Of course this will never work.  I think you need to read some books
about HTML and Web technologies first.

	Actually, we are making web-based applications, but not real network
applications.  In this technology, a web page is parsed (and executed 
in one
sense) by the server first and then by the client.

	The code between <script ... runat=3Dserver>....</script> is of course
_run_at_ server.  So, when the client browser receive the resultant web
page, this function no longer exists.  You can check this in page 
source.

	So your button couldn't execute anything because it can't find any
function called tester.

	Please also note that you can't trigger a function in server side.
What you can "trigger" is a whole page, ie an HTML page is processed 
and
included server-side functions/instructions are executed and a web page 
is
generated and sent to the client.

	So at most you could only "trigger" your tester function when the
web page is generated by calling it after its definition :
<!--
sub Tester()
....
End Sub

Tester
-->

> -----Message d'origine-----
> De : aneeqah vahed [mailto:aneeqahv@u...]
> Envoy=C3=A9 : lundi 23 d=C3=A9cembre 2002 14:39
> =C3=80 : ASP components
> Objet : [asp_components] Re: Execute server application from
> an ASP page
>
>
> I used the following code to try and execute the batch file
>
> <HTML><HEAD>
> <Script Language=3D"VBScript" runat=3D"server">
> <!--
> sub Tester()
> set wshShell =3D Server.CreateObject("WScript.Shell")
> wshShell.Run "cmd
> C:\\Inetpub\wwwroot\CourseEval\BATCHtester.bat" ,1,false
> set wshShell=3DNothing
> End Sub
> -->
> </Script>
> </head>
> <BODY><INPUT id=3Dbutton1 name=3Dbutton1 type=3Dbutton value=3DButton 

> onclick=3D "Tester()">
>

  Return to Index