@Test public void testScriptError() { assert !AppleScript.execute("blah", new StringBuilder()); }
public static boolean execute(String appleScript, StringBuilder outputBuffer) { if(!OsFamily.MAC_OS_X.isCurrent()) return false; LOGGER.debug("Executing AppleScript: "+appleScript); String tokens[] = new String[] { "osascript", "-s", "o", }; OutputStreamWriter pout = null; try { AbstractProcess process = ProcessRunner.execute(tokens, outputBuffer==null?null:new ScriptOutputListener(outputBuffer, AppleScript.getScriptEncoding())); pout = new OutputStreamWriter(process.getOutputStream(), getScriptEncoding()); pout.write(appleScript); pout.close(); int returnCode = process.waitFor(); LOGGER.debug("osascript returned code="+returnCode+", output="+ outputBuffer); if(returnCode!=0) { LOGGER.debug("osascript terminated abnormally"); return false; } return true; } catch(Exception e) { LOGGER.debug("Unexcepted exception while executing AppleScript", e); try { if(pout!=null) pout.close(); } catch(IOException e1) { } return false; } }
AppleScript { public static boolean execute(String appleScript, StringBuilder outputBuffer) { if(!OsFamily.MAC_OS_X.isCurrent()) return false; LOGGER.debug("Executing AppleScript: "+appleScript); String tokens[] = new String[] { "osascript", "-s", "o", }; OutputStreamWriter pout = null; try { AbstractProcess process = ProcessRunner.execute(tokens, outputBuffer==null?null:new ScriptOutputListener(outputBuffer, AppleScript.getScriptEncoding())); pout = new OutputStreamWriter(process.getOutputStream(), getScriptEncoding()); pout.write(appleScript); pout.close(); int returnCode = process.waitFor(); LOGGER.debug("osascript returned code="+returnCode+", output="+ outputBuffer); if(returnCode!=0) { LOGGER.debug("osascript terminated abnormally"); return false; } return true; } catch(Exception e) { LOGGER.debug("Unexcepted exception while executing AppleScript", e); try { if(pout!=null) pout.close(); } catch(IOException e1) { } return false; } } }
AppleScript { public static boolean execute(String appleScript, StringBuilder outputBuffer) { if(!OsFamily.MAC_OS_X.isCurrent()) return false; LOGGER.debug("Executing AppleScript: "+appleScript); String tokens[] = new String[] { "osascript", "-s", "o", }; OutputStreamWriter pout = null; try { AbstractProcess process = ProcessRunner.execute(tokens, outputBuffer==null?null:new ScriptOutputListener(outputBuffer, AppleScript.getScriptEncoding())); pout = new OutputStreamWriter(process.getOutputStream(), getScriptEncoding()); pout.write(appleScript); pout.close(); int returnCode = process.waitFor(); LOGGER.debug("osascript returned code="+returnCode+", output="+ outputBuffer); if(returnCode!=0) { LOGGER.debug("osascript terminated abnormally"); return false; } return true; } catch(Exception e) { LOGGER.debug("Unexcepted exception while executing AppleScript", e); try { if(pout!=null) pout.close(); } catch(IOException e1) { } return false; } }  }
AppleScript { public static boolean execute(String appleScript, StringBuilder outputBuffer) { if(!OsFamily.MAC_OS_X.isCurrent()) return false; LOGGER.debug("Executing AppleScript: "+appleScript); String tokens[] = new String[] { "osascript", "-s", "o", }; OutputStreamWriter pout = null; try { AbstractProcess process = ProcessRunner.execute(tokens, outputBuffer==null?null:new ScriptOutputListener(outputBuffer, AppleScript.getScriptEncoding())); pout = new OutputStreamWriter(process.getOutputStream(), getScriptEncoding()); pout.write(appleScript); pout.close(); int returnCode = process.waitFor(); LOGGER.debug("osascript returned code="+returnCode+", output="+ outputBuffer); if(returnCode!=0) { LOGGER.debug("osascript terminated abnormally"); return false; } return true; } catch(Exception e) { LOGGER.debug("Unexcepted exception while executing AppleScript", e); try { if(pout!=null) pout.close(); } catch(IOException e1) { } return false; } }  static boolean execute(String appleScript, StringBuilder outputBuffer); static String getScriptEncoding(); }
AppleScript { public static boolean execute(String appleScript, StringBuilder outputBuffer) { if(!OsFamily.MAC_OS_X.isCurrent()) return false; LOGGER.debug("Executing AppleScript: "+appleScript); String tokens[] = new String[] { "osascript", "-s", "o", }; OutputStreamWriter pout = null; try { AbstractProcess process = ProcessRunner.execute(tokens, outputBuffer==null?null:new ScriptOutputListener(outputBuffer, AppleScript.getScriptEncoding())); pout = new OutputStreamWriter(process.getOutputStream(), getScriptEncoding()); pout.write(appleScript); pout.close(); int returnCode = process.waitFor(); LOGGER.debug("osascript returned code="+returnCode+", output="+ outputBuffer); if(returnCode!=0) { LOGGER.debug("osascript terminated abnormally"); return false; } return true; } catch(Exception e) { LOGGER.debug("Unexcepted exception while executing AppleScript", e); try { if(pout!=null) pout.close(); } catch(IOException e1) { } return false; } }  static boolean execute(String appleScript, StringBuilder outputBuffer); static String getScriptEncoding(); final static String UTF8; final static String MACROMAN; }