Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 322 Vote(s) - 3.63 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to collect output from running Java applet via JScript in Windows command prompt?

#1
I am trying to automate compression of multiple JS/CSS files with the [YUI Compressor][1]. Each time I basically need to run the following Java command:

> java -jar yuicompressor-2.4.8.jar "script in.js" -o "script out.js"


So I do it using Microsoft's JScript engine:


var oShell = WScript.CreateObject("WScript.Shell");

var scriptIn = "script in.js";
var scriptOut = "script out.js";

var strRun = "java -jar yuicompressor-2.4.8.jar \"" + scriptIn + "\" -o \"" + scriptOut + "\"";

oShell.Run(strRun, 0, true);


This works fine, except that it doesn't give me any output from the compressor. Note that if I put that same line of Java code in a .bat file and run it from a command line, it gives me the output from running the command (YUI Compressor's warnings, errors, etc.)

So I'm curious, how do I collect it via my JScript?


[1]:

[To see links please register here]

Reply

#2
Use .Exec instead of .Run and capture the objects StdErr:

var exec = oShell.Exec(strRun);
WScript.Echo(exec.StdErr.ReadAll());

(specify --verbose in strRun; use the [docs][1] to replace the hack above with a more robust version that checks .Status and .StdErr.AtEndOfStream)


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through