aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Start script to display error messages?  (Read 5558 times)

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Start script to display error messages?
« on: January 01, 2009, 10:39:52 PM »

Hello to our Mac specialists,

there are sometimes user reports about aMule not opening, apparently without an error message. The standard response is to start aMule in a terminal to see the error.

Wouldn't it be nice if we had a script which caught the output of aMule and displayed the output in a message in case of an error?

An out of the head bash example:
Code: [Select]
amule | tee amule.out
if [ "0" != "$?" ]; then dialog "$(cat amule.out) 0 0; fi

Is there any Mac user who would know how to go about this?
Logged

bongo

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 37
Re: Start script to display error messages?
« Reply #1 on: January 05, 2009, 10:58:09 PM »

perhaps this applescript can help.
you select your amule.app (the script adds the path to the binary in the package) and then amule gets started from shell. after closing amule the output is saved to the file output.txt on your desktop.
i can't try it with a non-starting amule because it works here but in theory it should't make a difference if you close it or if it close itself because of an error.


Code: [Select]
on run
set amulePath to choose file of type "APPL" with prompt "Please select your Amule:"
set amulePath to POSIX path of amulePath
set amulePath to amulePath & "Contents/MacOS/amule" as text
-- show path
-- display dialog amulePath
do shell script amulePath
set the_output to the result
-- save output to file
set theFileName to (path to desktop folder as text) & "output.txt"
try
close access file theFileName
end try

set theFileName to open for access file theFileName with write permission
write the_output to theFileName
close access theFileName
-- display output (optional)
-- display dialog the_output default button {"OK"}
end run

Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: Start script to display error messages?
« Reply #2 on: January 06, 2009, 06:27:47 PM »

Thanks a lot for your help, this will make resolving errors much easier for everyone involved!

Oh: Excuse my ignorant question, but executing an applescript is as easy as double clicking on the file, isn't it?
Logged

bongo

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 37
Re: Start script to display error messages?
« Reply #3 on: January 06, 2009, 08:55:09 PM »

a good question. in fact the former upload opens in script editor where you have to click  the "run" button. so here it is saved as runtime.
you can open it in scripteditor anyways just to be sure it doesn't burn your house.  ;)
Logged