aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: "Download completed" event problems, "Failed to execute..", "code '1'"  (Read 3277 times)

raffe1234

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14

After an update of my Qnap NAS I started to get
Failed to execute command '/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"' on `Download completed' event.

When I test
/opt/sbin/aMuleMail.sh 1 2 3 4 5
I get an e-mail

After reading this thread  http://forum.amule.org/index.php?topic=17422.0 I tried to add "sleep 5" into aMuleMail.sh, but then I got
Command '/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"' with pid '860' has finished with status code '1'.

The I changed to "sleep 1", but still "code '1'"

"Code '1'" sounds better than "Failed to execute..", but as I don't get any e-mail something seem to be wrong. What is "code 1" and what do you think I am doing wrong?

Some more from the log, maybe you need it? (it´s Qnap that wants to run it as root, not me ;-) )
Code: [Select]
2017-05-22 22:14:28: Initialising aMuleD 2.3.1 compiled with wxGTK2 v2.8.12
 2017-05-22 22:14:28: Checking if there is an instance already running...
 2017-05-22 22:14:28: No other instances are running.
!2017-05-22 22:14:28: ERROR: WARNING Warning! You are running aMule as root.
!2017-05-22 22:14:28: Doing so is not recommended for security reasons,
!2017-05-22 22:14:28: and you are advised to run aMule as an normal
!2017-05-22 22:14:28: user instead.
 2017-05-22 22:14:28: Creditfile loaded, 5458 clients are known
 2017-05-22 22:14:28: *** TCP socket (ECServer) listening on 0.0.0.0:4712
 2017-05-22 22:14:28: Created Server UDP-Socket at port 4665
 2017-05-22 22:14:28: ListenSocket: Ok.
 2017-05-22 22:14:28: Created Client UDP-Socket at port 4672
 2017-05-22 22:14:28: amuled: forking to background - see you
 2017-05-22 22:14:29: Loading server.met file: /root/.aMule/server.met
!2017-05-22 22:14:29: 9 servers in server.met found
 2017-05-22 22:14:29: Loading temp files from /share/Multimedia/aMule/Temp.
 2017-05-22 22:14:29: Loading PartFile 1 of 28
 2017-05-22 22:14:29: Loading PartFile 2 of 28
 2017-05-22 22:14:29: Loading PartFile 27 of 28
 2017-05-22 22:14:29: Loading PartFile 28 of 28
 2017-05-22 22:14:29: All PartFiles Loaded.
 2017-05-22 22:14:29: Found 28 part files
 2017-05-22 22:14:29: Adding file /share/Multimedia/aMule/Temp/045.part.met to shares
 2017-05-22 22:14:29: Adding file /share/Multimedia/aMule/Temp/043.part.met to shares
 2017-05-22 22:14:29: Adding file /share/Multimedia/aMule/Temp/002.part.met to shares
 2017-05-22 22:14:29: Adding file /share/Multimedia/aMule/Temp/001.part.met to shares
 2017-05-22 22:14:29: Found 48 known shared files
 2017-05-22 22:14:29: amuled: OnInit - starting timer
 2017-05-22 22:14:29: Loading IP filters 'ipfilter.dat' and 'ipfilter_static.dat'.
 2017-05-22 22:14:29: Loaded 0 IP-ranges from '/root/.aMule/ipfilter.dat'.
 2017-05-22 22:14:29: Loaded 0 IP-ranges from '/root/.aMule/ipfilter_static.dat'.
 2017-05-22 22:14:29: IP filter is ready
!2017-05-22 22:14:29: Connecting
 2017-05-22 22:14:29: Connecting to TheServer
 2017-05-22 22:14:29: Read 179 Kad contacts
!2017-05-22 22:14:29: Kad started.
 2017-05-22 22:14:29: New external connection accepted
 2017-05-22 22:14:29: Connecting client: aMuleweb 2.3.1
 2017-05-22 22:14:29: Access granted.
!2017-05-22 22:14:30: Kad stopped.
!2017-05-22 22:14:30: Connected to Kad (firewalled)
 2017-05-22 22:22:51: New external connection accepted
 2017-05-22 22:22:51: Connecting client: amule-remote 0x0001
 2017-05-22 22:22:51: Access granted.
!2017-05-22 22:23:47: Finished downloading: ubuntu.iso
 2017-05-22 22:23:55: Command '/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"' with pid '22165' has finished with status code '1'.
Logged

raffe1234

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14

Here is some more info, maybe you need it. aMuleMail.sh is based on the example at http://wiki.amule.org/wiki/Events#Linux

I have put the sleep stuff here:
Code: [Select]
#!/bin/bash
#
# aMuleMail.sh - sends an email upon completion of an aMule download
# Used in conjuction with aMule's Event feature
#
# Call like this: aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
#
# Lets wait...
sleep 1
# Enter your email address here:
... (and so on)
...
Logged

Vollstrecker

  • Administrator
  • Hero Member
  • *****
  • Karma: 67
  • Offline Offline
  • Posts: 1546
  • Unofficial Debian Packager
    • http://vollstreckernet.de

Maybe it helps if you put - e as parameter after the bash call in the first line, then you see at least, if anything inside the script fails.
Logged
Homefucking is killing prostitution

raffe1234

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
Re: "Download completed" event problems, "Failed to execute..", "code '1'"
« Reply #3 on: August 09, 2017, 11:35:11 AM »

I tried -e and also I made the script to write into a log file after every line. The log only showed that it failed at random lines, so I couldn't pin point the error. So I forgot the whole problem and continued with my life, maybe with a scar in my soul.

Today I started to wonder if there may be some problems with the rights in Qnaps OS, it was a auto script that was supposed to run at boot. So I finally also resolved this problem (not a good and nice solution, but it works).

1. In amule.conf I have this
Code: [Select]
[UserEvents/DownloadCompleted]
CoreEnabled=1
CoreCommand=/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
GUIEnabled=1
GUICommand=/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"


2. In aMuleMail.sh I have this (I run the 'real' e-mail script aMuleMailSend.sh from aMuleMail.sh with sudo (e.g. as root) and the echo part gives sudo the root password, so not very secure as someone may see root password i clear text in that file)
Code: [Select]
#!/bin/bash
echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "$1" "$2" $3 $4 "$5"

And now it works  :) . As aMule already runs as "admin" (the "root" in Qnap) it should work without this, but I guess they have done something wrong.

I guess I could do this much shorter with just change amule.conf to
Code: [Select]
[UserEvents/DownloadCompleted]
CoreEnabled=1
CoreCommand=echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
GUIEnabled=1
GUICommand=echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"


But now it works, and I am like "If it works, don't fix it" right now  ;)

I wonder if I can run sudo without the echo part? On a normal system maybe something in /usr/etc/sudoers, but it has "admin ALL=(ALL) ALL" but it still didn't work.
Logged