Hi Christopher,

> -----Original Message-----
> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Sent: Wednesday, June 18, 2014 7:05 PM

> >> First, I want the script to fetch as much stuff as possible for the user
> >> instead of relying on a great deal of previously-installed software. My
> >> current requirements -- other than MSVC++ -- are for wget.exe and
> >> 7za.exe to be available. If anyone knows how to script an HTTP download
> >> or a ZIP-decompress from a Windows command-line without either of
> those
> >> tools, I'd greatly appreciate some insight.
> >
> > Maybe Java + Apache Ant?
> >
> > Or maybe NAnt has some tasks for that
> > http://nant.sourceforge.net/
> 
> I considered Nant, but I wanted to limit the dependencies required to
> build tcnative.

Would Windows Powershell in this case work for you (as mentioned in my previous 
email)?
For example, to download a ZIP file and extract it, you could use a script like 
this that downloads Tomcat 8.0.8 x64 ZIP file and extract it to a "work" 
subfolder:

[[[
try
{
    # Add "System.IO.Compression.FileSystem" assembly so we can extract ZIP 
archives.
    # Note: This requires .Net 4.5 or higher (included since Windows 8 / Server 
2012)
    Add-Type -AssemblyName System.IO.Compression.FileSystem

    # Work folder where we download and extract files.
    $workFolder = Join-Path $pwd "work"

    # Remove the work folder if it exists, then (re-)create it.
    If (Test-Path $workFolder) {
        Remove-Item $workFolder -Recurse
    }
    (New-Item $workFolder -ItemType directory) | Out-Null

    $downloadUrl = 
"http://apache.openmirror.de/tomcat/tomcat-8/v8.0.8/bin/apache-tomcat-8.0.8-windows-x64.zip";
    $downloadPath = Join-Path $workFolder "MyTomcatDownload.zip"

    Write-Host "Downloading $downloadUrl to $downloadPath ..."
    Write-Host ""

    # Note: "Invoke-WebRequest http://xxx -OutFile xxx" will read the whole 
content to memory, then writing it to disk.
    (New-Object System.Net.WebClient).DownloadFile($downloadUrl, $downloadPath)

    # Extract the ZIP archive to the current directory.
    Write-Host "Extracting ZIP archive..."
    Write-Host ""
    [System.IO.Compression.ZipFile]::ExtractToDirectory($downloadPath, 
$workFolder)

    Write-Host "Finished."
}
catch
{
    Write-Host ("Exception: " + $_.Exception.GetType().FullName) 
-ForegroundColor Red
    Write-Host ("Message: " + $_.Exception.Message) -ForegroundColor Red
}
]]]


To run the script if it is saved as "MyScript1.ps" in the current directory, 
you can use the following command (setting ExecutionPolicy is required to allow 
to run scripts in the current session):

Powershell.exe -ExecutionPolicy RemoteSigned .\MyScript.ps1


Hope this helps.

Regards,
Konstantin Preißer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to