Bitcoin Forum
May 09, 2024, 11:18:44 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bash script help needed  (Read 583 times)
lassdas (OP)
Legendary
*
Offline Offline

Activity: 3649
Merit: 1412


View Profile
July 04, 2016, 09:36:17 AM
 #1

Moin Ihrs,

ich bastel hier schon ne ganze Weile rum und komm irgendwie nich weiter,
auch extrem-google'ing brachte bisher keine brauchbaren Ergebnisse,
aber Ihr seid ja schlau  und könnt mir bestimmt weiterhelfen.  Smiley

Folgende Situation:
Ich hab ein bash Script, das checken soll, wieviele Verbindungen mein Node gerade hat.
Code:
#!/bin/bash
# connections.sh
..snip..

n=`bitcoin-cli getconnectioncount | awk '{printf "%d", $1}'`
printf "%d" "$n" > /hdd/conn.txt
echo "$n written to conn.txt"

..snip..

Rufe ich das Script händisch auf, is alles gut,
Code:
pi@raspi2:~ $ ~/connections.sh
24 written to conn.txt
lass ich's aber als cronjob laufen (Benutzer crontab -e),
Code:
*/5 * * * * nice /bin/bash /home/pi/connections.sh >/dev/null 2>&1
bleibt $n leer und es wird entweder 0 (bei Verwendung von printf), oder garnix (bei Verwendung von echo) in die conn.txt geschrieben.

Ich wüsste echt gerne, warum, also falls irgendwer ne Idee hat...her damit.
1715253524
Hero Member
*
Offline Offline

Posts: 1715253524

View Profile Personal Message (Offline)

Ignore
1715253524
Reply with quote  #2

1715253524
Report to moderator
1715253524
Hero Member
*
Offline Offline

Posts: 1715253524

View Profile Personal Message (Offline)

Ignore
1715253524
Reply with quote  #2

1715253524
Report to moderator
Whoever mines the block which ends up containing your transaction will get its fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715253524
Hero Member
*
Offline Offline

Posts: 1715253524

View Profile Personal Message (Offline)

Ignore
1715253524
Reply with quote  #2

1715253524
Report to moderator
fronti
Legendary
*
Offline Offline

Activity: 2909
Merit: 1307



View Profile
July 04, 2016, 09:43:23 AM
 #2

Moin Ihrs,

ich bastel hier schon ne ganze Weile rum und komm irgendwie nich weiter,
auch extrem-google'ing brachte bisher keine brauchbaren Ergebnisse,
aber Ihr seid ja schlau  und könnt mir bestimmt weiterhelfen.  Smiley

Folgende Situation:
Ich hab ein bash Script, das checken soll, wieviele Verbindungen mein Node gerade hat.
Code:
#!/bin/bash
# connections.sh
..snip..

n=`bitcoin-cli getconnectioncount | awk '{printf "%d", $1}'`
printf "%d" "$n" > /hdd/conn.txt
echo "$n written to conn.txt"

..snip..

Rufe ich das Script händisch auf, is alles gut,
Code:
pi@raspi2:~ $ ~/connections.sh
24 written to conn.txt
lass ich's aber als cronjob laufen (Benutzer crontab -e),
Code:
*/5 * * * * nice /bin/bash /home/pi/connections.sh >/dev/null 2>&1
bleibt $n leer und es wird entweder 0 (bei Verwendung von printf), oder garnix (bei Verwendung von echo) in die conn.txt geschrieben.

Ich wüsste echt gerne, warum, also falls irgendwer ne Idee hat...her damit.


Findet das per cron aufgerufne Programm auch den Bitcoin-cli ? gib da mal den vollen Pfad an.

Weiter, warum nicht einfach
Code:
*/5 * * * * /home/pi/connections.sh >/dev/null 2>&1
in der Crontab? (das script mit chmod +x ausführbar machen)



If you like to give me a tip:  bc1q8ht32j5hj42us5qfptvu08ug9zeqgvxuhwznzk

"Bankraub ist eine Unternehmung von Dilettanten. Wahre Profis gründen eine Bank." Bertolt Brecht
lassdas (OP)
Legendary
*
Offline Offline

Activity: 3649
Merit: 1412


View Profile
July 04, 2016, 10:17:59 AM
 #3

Jaa, ich wusste doch, daß Ihr schlau seid.  Cheesy
Mit /usr/local/bin/bitcoin-cli getconnectioncount klappts tatsächlich.

Der Benutzer-crontab weiß wohl dochnich soviel, wie der Benutzer.

Ich danke Dir.

Weiter, warum nicht einfach
Code:
*/5 * * * * /home/pi/connections.sh >/dev/null 2>&1
in der Crontab? (das script mit chmod +x ausführbar machen)
Das hatt ich ja vorher auch,
/bin/bash war einer von vielen verzweifelten Versuchen, das Problem zu umgehen (genau wie das eigentlich überflüssige | awk '{ printf "%d", $1}' hinterm getconnectioncount), hat nur nix genützt.  Cool
husel2000
Hero Member
*****
Offline Offline

Activity: 581
Merit: 504


View Profile
July 04, 2016, 10:44:27 AM
 #4

was sagt den:
which bitcoin-cli

lassdas (OP)
Legendary
*
Offline Offline

Activity: 3649
Merit: 1412


View Profile
July 04, 2016, 10:55:03 AM
 #5

Na,
Code:
pi@raspi2:~ $ which bitcoin-cli
/usr/local/bin/bitcoin-cli
und wie bereits erwähnt klappts damit ja auch endlich per cron.

Ein Problem gelöst, aber das nächste lässt bestimmt nich lange auf sich warten.  Grin
Pages: [1]
  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!