[thelist] Execute external command in ASP

Canfield, Joel JCanfield at PacAdvantage.org
Tue Jul 26 10:10:12 CDT 2005


> is there a way to execute and external command-line program in classic
> ASP and capture its output? I'm looking for something similar to the
> system() command in PHP.

I've used WSCRIPT.SHELL to automate command line ftp, among other
things. Here's a snippet of code, in case it's helpful:

----------------------------------------

Set oScript = Server.CreateObject("WSCRIPT.SHELL")

'**********************************************************
' create command string, map path to the ftp command file
' created above, create temp file for logging
'**********************************************************
strCMD = "ftp.exe -s:" & Server.MapPath("vendor.ftp")
strLogFile = "C:\Inetpub\wwwroot\it\transmissions\logs\vendor" &
datDataDate & ".log"

'**********************************************************
' run the command, output to the temp file, then read it
'
'**********************************************************
Call oScript.Run("cmd.exe /c " & strCMD & " > " & strLogFile, 0, True)
Set oFile = objFSO.OpenTextFile (strLogFile, 1, False, 0)

----------------------------------------

joel


More information about the thelist mailing list