• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: External Command Call part 1 of 2 - More Java Than WebObjects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: External Command Call part 1 of 2 - More Java Than WebObjects


  • Subject: Re: External Command Call part 1 of 2 - More Java Than WebObjects
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Tue, 08 Jul 2003 23:33:41 +0100

Hi Bob,
Thanks for the code example, but i'm still having trouble getting it to run.

I've set this up the command line as a static string that I know works as a command line in the shell just so that i can see this working from a form button. The code I am working from for the output is this -

protected WOComponent convertToThumb() throws IOException
   {
       String stdout = "cmd";

Runtime runtime = Runtime.getRuntime();
NSLog.out.appendln("===\r convertToThumb -- Runtime.getRuntime() = " + Runtime.getRuntime());


String optionArgs = " -size 90x90 " + "\\Apple\\web\\WebObjects\\JandMGeneralMaintenance.woa\\Contents\\WebServerResources\\fullSizeImages800pix\\Conservatory4ChairDinner.jpg" + " -resize 90x90 +profile \"*\" " + "\\Apple\\web\\WebObjects\\JandMGeneralMaintenance.woa\\Contents\\WebServerResources\\fullSizeImages800pix\\Conservatory4ChairDinnerThumb.jpg";
NSLog.out.appendln("===\r convertToThumb -- optionArgs = " + optionArgs);


String pathToScriptFolder = System.getProperty("c:\\imagemagick-5.5.7-q8\\");
String scriptName = System.getProperty("convert");


String[] args = new String[]{stdout + System.getProperty("line.separator") + " " + "sh" + System.getProperty("line.separator") + "c:\\imagemagick-5.5.7-q8\\" + "convert" + optionArgs};
NSLog.out.appendln("===\r convertToThumb -- String[] args = " + args);


try {
Process p = runtime.exec(args);
NSLog.out.appendln("===\r convertToThumb -- Process p = " + p);
p.waitFor();
int exitValue = p.exitValue();


InputStream is = p.getInputStream();
NSLog.out.appendln("===\r convertToThumb -- p.getInputStream() = " + p.getInputStream());
InputStreamReader isr = new InputStreamReader(is);
//OutputStreamReader osr = new OutputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
NSLog.out.appendln("===\r convertToThumb -- BufferedReader br = " + br);


String line = br.readLine();
while (line != null) {
stdout = stdout + line;
line = br.readLine();
NSLog.out.appendln("===\r convertToThumb -- String line = " + line);
}


// THIS PROCESS RETURNS SOME VALUES BY INTERNALLY DEFINED PROTOCOLS
// so you have to customize this


if(exitValue > 128) exitValue -= 256;
switch(exitValue) {
case -4: // WARNING
NSLog.out.appendln("Warning : convertToThumb : stdout : " + stdout);
break;
case -3: // ERROR
NSLog.out.appendln("Error : convertToThumb : stdout : " + stdout);
break;
case -2: // FILE_NOT_FOUND
NSLog.out.appendln("Error : convertToThumb : stdout : " + stdout);
break;
case -1: // INVALID_PARAMETERS
NSLog.out.appendln("Error : convertToThumb : stdout : " + stdout);
break;
default: // OK
NSLog.out.appendln("Info : convertToThumb : stdout : " + stdout);



FileInputStream fis = new FileInputStream(this.TMP_FILE);
int chunkSize = fis.available();
NSLog.out.appendln("===\r convertToThumb -- chunkSize : " + chunkSize);


this.data = new NSData(fis, chunkSize);
this.mimeType = "text/plain";
this.isSaveAsOption = true;
this.fileName = "m" + this.m_somethiing
+ "p" + this.p_somethiing
+ "o" + this.o_somethiing
+ ".extension";
}
this.message = stdout;
NSLog.out.appendln("===\r convertToThumb -- stdout : " + stdout);


       } catch (IOException e) {
           NSLog.out.appendln("executeSomeScript : " + e);
       } catch (InterruptedException e) {
           NSLog.out.appendln("executeSomeScript : " + e);
       }

       return null;

   }

- and what I get output in the launch window is this:

===
convertToThumb() -- Runtime.getRuntime() = java.lang.Runtime@28773c
===
convertToThumb() -- optionArgs = -size 90x90 \Apple\web\WebObjects\JandMGeneralMaintenance.woa\Contents\WebServerResources\fullSizeImages800pix\Conservatory4ChairDinner.jpg -resize 90x90 +profile "*" \Apple\web\WebObjects\JandMGeneralMaintenance.woa\Contents\WebServerResources\fullSizeImages800pix\Conservatory4ChairDinnerThumb.jpg
===
convertToThumb() -- String[] args = [Ljava.lang.String;@2c3327
executeSomeScript : java.io.IOException: CreateProcess: "cmd
sh
c:\imagemagick-5.5.7-q8\convert -size 90x90 \Apple\web\WebObjects\JandMGeneralMaintenance.woa\Contents\WebServerResources\fullSizeImages800pix\Conservatory4ChairDinner.jpg -resize 90x90 +profile "*" \Apple\web\WebObjects\JandMGeneralMaintenance.woa\Contents\WebServerResources\fullSizeImages800pix\Conservatory4ChairDinnerThumb.jpg" error=2
==============================================================


THIS POST CONTINUES ON... Re: External Command Call 2 0f 2 - More Java Than WebObjects

In this first example I use System.getProperty("line.separator") to simulate the user pressing "enter" when they would write "cmd" and then "sh" and then the command line code itself. Whether this is correct or not i don't know, I'm experimenting to get this to work, but obviously with no joy.

The other example on the part 2 of 2 post is closer to the original code that was sent to me and you will see the error i am getting with that too.

I believe i'm not using this code at all correctly.
Where am I going wrong with these?

Jonathan :^/

_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today! http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: External Command Call part 2 of 2 - More Java Than WebObjects
  • Next by Date: Re: External Command Call [ LATEST ] - More Java Than WebObjects
  • Previous by thread: Re: External Command Call part 2 of 2 - More Java Than WebObjects
  • Next by thread: Re: External Command Call [ LATEST ] - More Java Than WebObjects
  • Index(es):
    • Date
    • Thread