aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: How to start amule in a shell script on MacOSX ?  (Read 2408 times)

mikool19

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
How to start amule in a shell script on MacOSX ?
« on: November 21, 2006, 06:52:53 PM »

Hi,
i'm new, french (i don't speak english very well...) and sorry if the answer is somewhere but i did'nt find it.

I have aMule 2.1.3 installed on my Mac (G5 with OSX 10.4.8). aMule starts very well if i double-clic on it in the Finder but sometimes it crashes (after a few hours or days...) without any known reason. I have looked up in the amule log without success.

So, i have written a very little script in tcsh for controling if amule is working (with crontab) and, if not, starts amule with a very simple command. Here's the script :
Code: [Select]
#!/bin/tcsh -f
set aMule_state = "`ps -awwx | grep "aMule.app/Contents/MacOS/amule" | grep -v grep`"
if ("$aMule_state" == "") then
/Users/rozenn/Desktop/aMule-2.1.3-Mac_UniversalBinary_TigerOnly/aMule.app/Contents/MacOS/amule&
endif
When crontab executes the script, aMule tries to start but the Finder shows a message which says "Close, restart, send a report" because aMule starting has failed . But if i type just the command directly in a terminal to start amule, it works fine !!

So, i have 2 questions :
- why is the same command working directly in a terminal to launch amule and not in a shell script (working with crontab) ?
- what is the good command (and what are the options supported by amule (-h is very short...)) to start it in a shell script ?

Opionnaly, if you know why aMule quits when running, it's interesting also (but i don't give you enough details i suppose).

Thanks in advance.

PS : any advice or suggestion is welcome.
« Last Edit: November 22, 2006, 07:10:16 PM by mikool19 »
Logged

mikool19

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
Re: How to start amule in a shell script on MacOSX ?
« Reply #1 on: November 22, 2006, 11:11:41 PM »

The solution is to not use crontab but a script in a loop with a while command like that :
Code: [Select]
#!/bin/tcsh -f

while (1)
set aMule_state = "`ps -awwx | grep "aMule.app/Contents/MacOS/amule" | grep -v grep`"
if ("$aMule_state" == "") then
/Users/gd/Applications/P2P/aMule.app/Contents/MacOS/amule --i-would-marry-my-mule &
endif
sleep 60
end
Here i use the last CVS aMule with the option --i-would-marry-my-mule but this version crashes also with crontab and not with the while command. I just have to make this script workable with Terminal (Command-I) and to put it in Startup for automatic startup.

I have found a workaround but not why aMule crashes and not why it's not working with crontab. So, i'm always interested by answers.
Logged

ken

  • Hero Member
  • *****
  • Karma: 4
  • Offline Offline
  • Posts: 825
Re: How to start amule in a shell script on MacOSX ?
« Reply #2 on: November 26, 2006, 04:13:17 PM »

It's been a while since I used aMule from a crontab.  It used to work, but things might have changed with new versions of the OS and/or new versions of wxWidgets.

The first thing that you need to know is: the user account under which the crontab script is run must be the same as the user who "owns" the GUI.  The user must be logged in, and must be switched in (with respect to Fast User Switching).  It is permissible for the GUI to be locked by the screensaver.

If it still doesn't work, the general problem is that crond is not a child of your login session process.  Therefore, any scripts that it runs don't have a complete connection to the Window Server.  It will acquire a connection if the above conditions are met, but there are still "issues" with it.

When I used to use crontab, this manifested as an inability to copy and paste between aMule and the rest of the GUI.

I hope that helps explain it to some extent.
Logged