jlp (OP)
|
|
March 11, 2015, 05:08:36 PM |
|
I have used the following successfully in bitcoin.conf for about a year: walletnotify=curl https://mydomain.com/walletnotify.php/?tanshash=%s blocknotify=curl https://mydomain.com/blocknotify.php/?blockhash=%s They seemed to stop working a few months ago. The following is in debug.log: 2015-03-11 14:05:53 runCommand error: system(curl https://mydomain.com/blocknotify.php/?blockhash=00000000000000000dd3c33eaf1a2746ebe841418b98cb15f4a0bb71f3330d5e) returned -1
I changed my code in bitcoin.conf to this: blocknotify=/usr/bin/php /home/mydomain/public_html/blocknotify.php %s But I'm still getting the same error: 2015-03-11 16:28:57 runCommand error: system(/usr/bin/php /home/mydomain/public_html/blocknotify.php 000000000000000015a51b99f54a611b2a88c096d1091e13933346431c17b2be) returned -1 Can anyone tell me what "runCommand error: ... returned -1" means and how to fix this?
|
|
|
|
grue
Legendary
Offline
Activity: 2058
Merit: 1434
|
|
March 11, 2015, 05:32:57 PM |
|
does it run successfully in in shell? as in, run the command, then do "echo $?" to check the return status.
|
|
|
|
jlp (OP)
|
|
March 11, 2015, 06:16:56 PM |
|
does it run successfully in in shell? as in, run the command, then do "echo $?" to check the return status.
Are you referring to this?: https://mydomain.com/blocknotify.php/?blockhash=00000000000000000dd3c33eaf1a2746ebe841418b98cb15f4a0bb71f3330d5e If so, then yes, that program executes when I invoke it from a browser. If you are suggesting that I add the following command in bitcoin.conf: blocknotify=/home/bitcoin/block.sh %s ...then that means I need to create a shell file. If you are suggesting that I have "echo $?" in the shell file, then I'm not sure how I would see the output. Doesn't the echo output go to the screen? If the shell program is running on the server, how do I see the output?
|
|
|
|
grue
Legendary
Offline
Activity: 2058
Merit: 1434
|
|
March 11, 2015, 08:25:04 PM |
|
as in, ssh into your server (I seriously hope you have ssh access) type: curl https://mydomain.com/blocknotify.php/?blockhash=00000000000000000dd3c33eaf1a2746ebe841418b98cb15f4a0bb71f3330d5e echo $?
the echo on the last line is to check the exit status. I'm suspecting that the culprit is your script failing and thus returning -1 to bitcoind when it's executed.
|
|
|
|
jlp (OP)
|
|
March 11, 2015, 09:07:21 PM |
|
Yes, I have SSH. Sorry, I didn't understand what you meant. I tried your suggestion and I can tell that it executed my PHP program, as I have code in it that sends me an email. However, SSH outputted the following: $ curl https://mydomain.com/blocknotify.php/?blockhash=1 echo $? curl: (6) Couldn't resolve host 'echo' <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href=" https://0/">here</a>.</p> </body></html> $ I don't know what that output means. Do you? Does this mean everything went as planned?
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
March 11, 2015, 10:09:54 PM |
|
cat >~/myscript.sh <<EOF #!/bin/bash echo hi there, starting >/tmp/log curl https://mydomain.com/blocknotify.php/?blockhash=42 >>/tmp/log 2>>/tmp/err echo exit code is $? >>/tmp/log EOF $ chmod +x myscript.sh Then "blocknotify=/home/<your user>/myscript.sh" in bitcoin.conf. After the next block, take a look to /tmp/log and /tmp/err. Next step: feed the 42 from the "blocknotify=" line, use $@ in the script. Next step: call curl directly with no wrapper.
|
|
|
|
jlp (OP)
|
|
March 12, 2015, 12:00:16 AM |
|
cat >~/myscript.sh <<EOF #!/bin/bash echo hi there, starting >/tmp/log curl https://mydomain.com/blocknotify.php/?blockhash=42 >>/tmp/log 2>>/tmp/err echo exit code is $? >>/tmp/log EOF $ chmod +x myscript.sh Then "blocknotify=/home/<your user>/myscript.sh" in bitcoin.conf. After the next block, take a look to /tmp/log and /tmp/err. Next step: feed the 42 from the "blocknotify=" line, use $@ in the script. Next step: call curl directly with no wrapper. Thanks for your suggestions. I created myscript.sh and changed bitcoin.conf as per your suggestions. Then I did this: $ bitcoind stop Bitcoin server stopping $ bitcoind -daemon Bitcoin server starting
$ bitcoind getinfo { "version" : 90000, "protocolversion" : 70002, "walletversion" : 60000, "balance" : X.XXXXXX, "blocks" : 347231, "timeoffset" : 0, "connections" : 8, "proxy" : "", "difficulty" : 47427554950.64830017, "testnet" : false, "keypoololdest" : 1396812248, "keypoolsize" : 84, "paytxfee" : 0.00000000, "unlocked_until" : 0, "errors" : "" } When I noticed that "blocks" (from bitcoind getinfo) increased, I checked the /tmp folder. But this folder only had cookies.txt, but log and err do not exist. I checked /home/myusername/.bitcoin/debug.log and saw this: 23:35:05 runCommand error: system(/home/myusername/myscript.sh) returned -1 Is it possible that there is something wrong in myscript.sh that is causing the runCommand error? When you say "call curl directly with no wrapper", are you saying to call curl directly from bitcoin.conf without using myscript.sh?
|
|
|
|
cr1776
Legendary
Offline
Activity: 4172
Merit: 1312
|
|
March 12, 2015, 12:04:59 AM |
|
Yes, I have SSH. Sorry, I didn't understand what you meant. I tried your suggestion and I can tell that it executed my PHP program, as I have code in it that sends me an email. However, SSH outputted the following: $ curl https://mydomain.com/blocknotify.php/?blockhash=1 echo $? curl: (6) Couldn't resolve host 'echo' <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href=" https://0/">here</a>.</p> </body></html> $ I don't know what that output means. Do you? Does this mean everything went as planned? Try the curl command on one line, then the echo command on a second line as it was in grue's example. It appears from the above that you did it all on one line.
|
|
|
|
jlp (OP)
|
|
March 12, 2015, 12:15:16 AM |
|
Try the curl command on one line, then the echo command on a second line as it was in grue's example.
It appears from the above that you did it all on one line.
Thanks for your keen observation. I indeed entered both commands on one line. Here's what I got now: $ curl https://mydomain.com/blocknotify.php/?blockhash=1 $ echo $? 0 $ What does the 0 mean? Should I try putting back the following into bitcoin.conf?: blocknotify=curl https://mydomain.com/blocknotify.php/?blockhash=%s
|
|
|
|
cr1776
Legendary
Offline
Activity: 4172
Merit: 1312
|
|
March 12, 2015, 05:03:39 PM |
|
Try the curl command on one line, then the echo command on a second line as it was in grue's example.
It appears from the above that you did it all on one line.
Thanks for your keen observation. I indeed entered both commands on one line. Here's what I got now: $ curl https://mydomain.com/blocknotify.php/?blockhash=1 $ echo $? 0 $ What does the 0 mean? Should I try putting back the following into bitcoin.conf?: blocknotify=curl https://mydomain.com/blocknotify.php/?blockhash=%s 0 should mean it returned successfully. If dserrano5's changes didn't create files in /tmp, that is odd unless there are permission problems there.
|
|
|
|
jlp (OP)
|
|
March 12, 2015, 05:26:53 PM |
|
If dserrano5's changes didn't create files in /tmp, that is odd unless there are permission problems there.
I got the following: $ ls -ld /tmp drwxrwxrwt 4 root root 4096 Mar 12 17:17 /tmp $ Am I correct to assume that the permissions for /tmp are fine? Do I need to change something in ~/myscript.sh in order to enable it to write to /tmp ?
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
March 12, 2015, 09:02:02 PM |
|
You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log . Then copy /bin/true to your home. "blocknotify=/home/<your username>/true". Nothing should happen again, no errors either. Another thing worth trying is "blocknotify=/bin/touch /tmp/foo" to weed out problems with spaces and that. After the next block /tmp/foo should exist, and of course no errors in the log.
|
|
|
|
jlp (OP)
|
|
March 12, 2015, 10:26:03 PM |
|
You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log . Then copy /bin/true to your home. "blocknotify=/home/<your username>/true". Nothing should happen again, no errors either. Another thing worth trying is "blocknotify=/bin/touch /tmp/foo" to weed out problems with spaces and that. After the next block /tmp/foo should exist, and of course no errors in the log. Thanks for your suggestions. I tried "blocknotify=/bin/true". I got the following in /home/username/.bitcoin/debug.log: 2015-03-12 22:12:47 runCommand error: system(/bin/true) returned -1 What does this error mean? I'm not exactly sure what you mean by "Then copy /bin/true to your home". I assume that you simply want me to try "blocknotify=/home/<your username>/true". I haven't tried this nor your suggestion with /tmp/foo, as I assumed that I'll get the runCommand error again. Let me know if I should anyways or if there isn't else I can try. Thanks.
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
March 12, 2015, 10:54:31 PM |
|
I tried "blocknotify=/bin/true". I got the following in /home/username/.bitcoin/debug.log: 2015-03-12 22:12:47 runCommand error: system(/bin/true) returned -1 Interesting. So you had this working for a year, then it suddenly broke "a few months ago" (as per the OP) to the point that not even a simple /bin/true works. Are you using apparmor o something similar?
|
|
|
|
cr1776
Legendary
Offline
Activity: 4172
Merit: 1312
|
|
March 12, 2015, 11:37:05 PM |
|
You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log . Then copy /bin/true to your home. "blocknotify=/home/<your username>/true". Nothing should happen again, no errors either. Another thing worth trying is "blocknotify=/bin/touch /tmp/foo" to weed out problems with spaces and that. After the next block /tmp/foo should exist, and of course no errors in the log. Thanks for your suggestions. I tried "blocknotify=/bin/true". I got the following in /home/username/.bitcoin/debug.log: 2015-03-12 22:12:47 runCommand error: system(/bin/true) returned -1 What does this error mean? I'm not exactly sure what you mean by "Then copy /bin/true to your home". I assume that you simply want me to try "blocknotify=/home/<your username>/true". I haven't tried this nor your suggestion with /tmp/foo, as I assumed that I'll get the runCommand error again. Let me know if I should anyways or if there isn't else I can try. Thanks. /bin/true should return a 0 /bin/false should return a non-zero, typically 1 (or -1) e.g. me@mine:~# /bin/true me@mine:~# echo $? 0 me@mine:~# /bin/false me@mine:~# echo $? 1
As dserrano5 said, it seems that "not even a simple /bin/true works." Try what I have as code above. Do you get something similar to the output above? /bin/true and /bin/false are useful for testing your logic when needed since you always know the result.
|
|
|
|
cr1776
Legendary
Offline
Activity: 4172
Merit: 1312
|
|
March 12, 2015, 11:39:24 PM |
|
Try the curl command on one line, then the echo command on a second line as it was in grue's example.
It appears from the above that you did it all on one line.
Thanks for your keen observation. I indeed entered both commands on one line. Here's what I got now: $ curl https://mydomain.com/blocknotify.php/?blockhash=1 $ echo $? 0 $ What does the 0 mean? Should I try putting back the following into bitcoin.conf?:
blocknotify=curl https://mydomain.com/blocknotify.php/?blockhash=%s Just to respond once more to this, the 0 should indicate that it returned success (like /bin/true), or no error, which is a good thing.
|
|
|
|
jlp (OP)
|
|
March 13, 2015, 12:49:19 AM |
|
Interesting. So you had this working for a year, then it suddenly broke "a few months ago" (as per the OP) to the point that not even a simple /bin/true works. Are you using apparmor o something similar?
I just checked my system and I have it: /etc/apparmo /etc/appmor.d However, I have never seen it anywhere before you mentioned it. Should I try changing something in it?
|
|
|
|
jlp (OP)
|
|
March 13, 2015, 12:56:49 AM |
|
me@mine:~# /bin/true me@mine:~# echo $? 0 me@mine:~# /bin/false me@mine:~# echo $? 1
As dserrano5 said, it seems that "not even a simple /bin/true works." Try what I have as code above. Do you get something similar to the output above? /bin/true and /bin/false are useful for testing your logic when needed since you always know the result. I got the same output as you did: $ /bin/true $ echo $? 0 $ /bin/false $ echo $? 1 $ I'm still getting the following in /home/username/.bitcoin/debug.log: 2015-03-13 00:41:32 runCommand error: system(/bin/true) returned -1
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
March 13, 2015, 07:20:13 AM |
|
I'm still getting the following in /home/username/.bitcoin/debug.log: 2015-03-13 00:41:32 runCommand error: system(/bin/true) returned -1 That has nothing to do with the result of the program. The error means that bitcoin core is unable to run /bin/true and that's the problem you have to tackle.
|
|
|
|
jlp (OP)
|
|
March 13, 2015, 03:57:57 PM |
|
That has nothing to do with the result of the program. The error means that bitcoin core is unable to run /bin/true and that's the problem you have to tackle.
Thanks for your help. Do you have any ideas on what I can try next?
|
|
|
|
|