@mwittig I also would prefer the days HH:MM
format. Think that the second one is way too long.
-
System Uptime shellsensor device
-
@jensebub and @leader21 : With regard to your differences in the uptime and sed, awk etc.
That is due to the fact that bananapi (on bananian) uses by default the zsh shell where debian on RPi uses the bash shell.
Please try on a command promptecho $SHELL
and you will (most probably) see.
To get the same output you need to switch to the bash shell on bananapi. That’s also why it works when using a script where you put the#!/bin/bash
as shebang in the top line: it will use the bash shell.This thread was more than a year old, but “woken from the dead”. That’s why I was triggered.
-
Thx harry for the info on bananaPi!
The uptime script in post no.1 works on both. Actually there are efforts to get the uptime from the systemsensor device into a better format.pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Hello, I apologize for the whole old themes.
But I have here also a mistake with “/”thats my uptime.sh
#!/bin/bash # uptime.sh # get uptime from /proc/uptime uptime=$(</proc/uptime) uptime=${uptime%%.*} seconds=$(( uptime%60 )) minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) days=$(( uptime/60/60/24 )) echo "$days Tage $hours Stunden $minutes Minuten $seconds Seconds" error [pimatic-shell-execute]: [ShellSensor#system-uptime] Error: Error getting attribute value for Uptime: /home/pi/uptime.sh: Zeile 4: $'\r': Kommando nicht gefunden. /home/pi/uptime.sh: Zeile 7: $'\r': Kommando nicht gefunden. /home/pi/uptime.sh: Zeile 8: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 9: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 10: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 11: 3732 : Syntaxfehler: Ungültiger arithmetischer Operator. (Fehlerverursachendes Zeichen ist \" \"). /home/pi/uptime.sh: Zeile 12: $'\r': Kommando nicht gefunden.
-
@wuschel The problem is, that your script has CR-LF line endings (DOS mode).
You need convert it to LF endings. You can use thedos2unix
helper to do so.sudo apt-get install dos2unix dos2unix uptime.sh
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig How has leader got the script to run? Or do you use “developer” all dos2unix?
-
@wuschel said in System Uptime shellsensor device:
How has leader got the script to run? Or do you use “developer” all dos2unix?
Well, it depends on how you create the file. It looks like your web browser is running on a windows system. If you create the file on the Windows system it will have the wrong line endings (CR-LF) unless you use a text editor which allows for setting the appropriate line endings for the target host (LF). Personally, I use kitty SSH (a putty derivative SSH client) to login into the Linux host. This way, I can copy-paste content between Windows and Linux hosts while the terminal emulation takes care of the conversion of line endings.
Btw, if you search the forum for dos2unix you’ll realize this is a common problem.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
as marcus said, if you do a copy / paste from a browser it could be that there are hidden characters or linefeeds etc. these can be cut off by using dos2unix.
i am running a windows machine and work with notepad++
this program has a built in ftp so that i am copying my codework directly from notepad++ to the linux pi.
so i am not having the problem with CR/LF and so on.pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
@wuschel For future posts containing code snippets or command transcripts please take the following into account. Thanks
https://forum.pimatic.org/topic/1179/how-to-post-code-snippets-and-alike-on-the-forum"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig said in System Uptime shellsensor device:
@wuschel For future posts containing code snippets or command transcripts please take the following into account. Thanks
https://forum.pimatic.org/topic/1179/how-to-post-code-snippets-and-alike-on-the-forumi will try it