Bitcoin Forum
April 24, 2024, 11:31:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: debug.log runCommand error  (Read 3300 times)
jlp (OP)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 11, 2015, 05:08:36 PM
 #1

I have used the following successfully in bitcoin.conf for about a year:

Code:
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:

Code:
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:

Code:
blocknotify=/usr/bin/php /home/mydomain/public_html/blocknotify.php %s

But I'm still getting the same error:

Code:
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?

1713958293
Hero Member
*
Offline Offline

Posts: 1713958293

View Profile Personal Message (Offline)

Ignore
1713958293
Reply with quote  #2

1713958293
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713958293
Hero Member
*
Offline Offline

Posts: 1713958293

View Profile Personal Message (Offline)

Ignore
1713958293
Reply with quote  #2

1713958293
Report to moderator
1713958293
Hero Member
*
Offline Offline

Posts: 1713958293

View Profile Personal Message (Offline)

Ignore
1713958293
Reply with quote  #2

1713958293
Report to moderator
grue
Legendary
*
Offline Offline

Activity: 2058
Merit: 1431



View Profile
March 11, 2015, 05:32:57 PM
 #2

does it run successfully in in shell? as in, run the command, then do "echo $?" to check the return status.

It is pitch black. You are likely to be eaten by a grue.

Adblock for annoying signature ads | Enhanced Merit UI
jlp (OP)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 11, 2015, 06:16:56 PM
 #3

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?:

Code:
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:

Code:
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 Offline

Activity: 2058
Merit: 1431



View Profile
March 11, 2015, 08:25:04 PM
 #4

as in, ssh into your server (I seriously hope you have ssh access)
type:
Code:
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.

It is pitch black. You are likely to be eaten by a grue.

Adblock for annoying signature ads | Enhanced Merit UI
jlp (OP)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 11, 2015, 09:07:21 PM
 #5

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 Offline

Activity: 1974
Merit: 1029



View Profile
March 11, 2015, 10:09:54 PM
 #6

Code:
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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 12, 2015, 12:00:16 AM
 #7

Code:
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:

Code:
$ 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:

Code:
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 Offline

Activity: 4018
Merit: 1299


View Profile
March 12, 2015, 12:04:59 AM
 #8

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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 12, 2015, 12:15:16 AM
 #9


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:

Code:
$ 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?:

Code:
blocknotify=curl https://mydomain.com/blocknotify.php/?blockhash=%s
cr1776
Legendary
*
Offline Offline

Activity: 4018
Merit: 1299


View Profile
March 12, 2015, 05:03:39 PM
 #10


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:

Code:
$ 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?:

Code:
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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 12, 2015, 05:26:53 PM
 #11


If dserrano5's changes didn't create files in /tmp, that is odd unless there are permission problems there.

I got the following:

Code:
$ 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 Offline

Activity: 1974
Merit: 1029



View Profile
March 12, 2015, 09:02:02 PM
 #12

You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log Wink.

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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 12, 2015, 10:26:03 PM
 #13

You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log Wink.

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:

Code:
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 Offline

Activity: 1974
Merit: 1029



View Profile
March 12, 2015, 10:54:31 PM
 #14

I tried "blocknotify=/bin/true".  I got the following in /home/username/.bitcoin/debug.log:

Code:
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 Offline

Activity: 4018
Merit: 1299


View Profile
March 12, 2015, 11:37:05 PM
 #15

You can try "blocknotify=/bin/true". Nothing should happen, not even an error in your log Wink.

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:

Code:
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.
Code:
 
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 Offline

Activity: 4018
Merit: 1299


View Profile
March 12, 2015, 11:39:24 PM
 #16


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:

Code:
$ 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?:

Code:
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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 13, 2015, 12:49:19 AM
 #17


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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 13, 2015, 12:56:49 AM
 #18


Code:
 
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:

Code:
$ /bin/true
$ echo $?
0
$ /bin/false
$ echo $?
1
$

I'm still getting the following in /home/username/.bitcoin/debug.log:

Code:
2015-03-13 00:41:32 runCommand error: system(/bin/true) returned -1
dserrano5
Legendary
*
Offline Offline

Activity: 1974
Merit: 1029



View Profile
March 13, 2015, 07:20:13 AM
 #19

I'm still getting the following in /home/username/.bitcoin/debug.log:

Code:
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)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 264


View Profile
March 13, 2015, 03:57:57 PM
 #20


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?

Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!