Custom MOTD - Message of the Day


48 posts   Page 1 of 2   1, 2
by yanewby » Wed Nov 21, 2012 4:41 pm
I have had my Pi for about 5 days now and have it set up in a headless configuration. I have quickly tired of seeing the standard ssh login message regarding GNU/Linux so I decided to play around a little bit and add something a little more useful (at least to me). I have attached my solution so far to this message.

Please feel free to play around with it, post improvements (my coding sucks) or post suggestions. Personally I would like to move the "Last login" text to the red text area but I haven't been able to work out how to determine this yet (I know how to disable it but I don't think that is a good idea).

rasplogin.jpg
rasplogin.jpg (33.9 KiB) Viewed 31588 times


To use this place the following code in "/home/pi/.bash_profile". You should probably put this somewhere else in /etc/motd.somewhere.or.other but I don't know where and couldn't work it out. .bash_profile worked for me. Maybe someone else will be able to tell us how?!

Code: Select all
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`

# get the load averages
read one five fifteen rest < /proc/loadavg

echo "$(tput setaf 2)
   .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
  '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
   .~ .~~~..~.   
  : .~.'~'.~. :   Uptime.............: ${UPTIME}
 ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
 ~ .~ (   ) ~. ~  Running Processes..: `ps ax | wc -l | tr -d " "`
  (  : '~' :  )   IP Addresses.......: `/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1` and `wget -q -O - http://icanhazip.com/ | tail`
   '~ .~~~. ~'    Weather............: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
       '~'
$(tput sgr0)"


The ASCII Raspberry Pi logo is from: http://www.raspberrypi.org/phpBB3/viewtopic.php?p=78678#p78678

Any suggestions, additions or improvements you'd like to make?
Posts: 8
Joined: Sun Nov 18, 2012 12:22 pm
by RaTTuS » Wed Nov 21, 2012 4:47 pm
you don't need to obscure local IP addresses ....
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
"That's not right, the badgers have moved the goalposts."
User avatar
Posts: 4954
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by yanewby » Wed Nov 21, 2012 4:48 pm
RaTTuS wrote:you don't need to obscure local IP addresses ....


I know but I wanted to :D
Posts: 8
Joined: Sun Nov 18, 2012 12:22 pm
by hop » Fri Nov 23, 2012 7:27 am
This looks great, I will be using this OP thanks!
User avatar
Posts: 87
Joined: Thu Nov 22, 2012 9:40 pm
by yanewby » Fri Nov 23, 2012 9:29 am
hop wrote:This looks great, I will be using this OP thanks!


I'm glad you like it and I hope you find it useful. If you can think of anything else you'd like reported on this screen, let me know and I will see if I can work out how to include it.

I have since added a "Free Disk Space" entry to my screen with the addition of this code:

Code: Select all
Free Disk Space....: `df -Pk | grep -E '^/dev/sda1' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /dev/sda1
Posts: 8
Joined: Sun Nov 18, 2012 12:22 pm
by ghans » Fri Nov 23, 2012 12:43 pm
I'm not using this currently , but thats a nice way to show off
UNIX tools :D (and your 1337 skillz of course )
Good work !


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4462
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by hop » Fri Nov 23, 2012 6:07 pm
yanewby wrote:
hop wrote:This looks great, I will be using this OP thanks!


I'm glad you like it and I hope you find it useful. If you can think of anything else you'd like reported on this screen, let me know and I will see if I can work out how to include it.

I have since added a "Free Disk Space" entry to my screen with the addition of this code:

Code: Select all
Free Disk Space....: `df -Pk | grep -E '^/dev/sda1' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /dev/sda1


It's always useful to know how your system is running.
User avatar
Posts: 87
Joined: Thu Nov 22, 2012 9:40 pm
by startreksteve » Mon Nov 26, 2012 8:45 am
How do I change my weather location? (Kingston upon Hull, UK)
Posts: 43
Joined: Tue Mar 13, 2012 10:23 am
by hop » Mon Nov 26, 2012 8:55 pm
startreksteve wrote:How do I change my weather location? (Kingston upon Hull, UK)


Come on.... :roll:

Read the source code and figure it out.
User avatar
Posts: 87
Joined: Thu Nov 22, 2012 9:40 pm
by haincha » Tue Nov 27, 2012 5:15 am
Thanks! I will be using this, as I use my Pi almost exclusively through ssh.
Posts: 16
Joined: Tue Sep 25, 2012 11:53 pm
by startreksteve » Tue Nov 27, 2012 8:33 am
I did...
"http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|"

and it wont seem to pull any data from the hull code
(accuweather.com/en/gb/kingston-upon-hull/hu1-3)

Hence the request for help.
the rss looks at eur|uk|
and the website looks at en|gb|
Posts: 43
Joined: Tue Mar 13, 2012 10:23 am
by startreksteve » Tue Nov 27, 2012 9:00 am
Got it!

curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|KINGSTON-UPON-HULL|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'

Delivers: 45°F, Mostly Cloudy W/ Showers
Change metric=1 to metric=0 for Farenheit
Dunno what UK001 does because whatever you change it to it still gives the same output.
Steve
Posts: 43
Joined: Tue Mar 13, 2012 10:23 am
by startreksteve » Tue Nov 27, 2012 4:01 pm
This site has a lot of region codes for Accuweather:
http://pastebin.com/dbtemx5F
Posts: 43
Joined: Tue Mar 13, 2012 10:23 am
by azeam » Tue Nov 27, 2012 7:06 pm
If you fill in the information at http://netweather.accuweather.com/signup-page1.asp?partner=&traveler=0 you will get the area code in a HTML snippet.

I followed the guide at http://www.mewbies.com/how_to_customize_your_console_login_message_tutorial.htm to make a custom MOTD. The shorter version, including some minor differences for the Rpi, is remove the contents of
Code: Select all
/etc/motd
comment out
Code: Select all
uname -snrvm > /var/run/motd.dynamic
in
Code: Select all
/etc/init.d/motd
Change from "PrintLastLog yes" to
Code: Select all
PrintLastLog no
in
Code: Select all
/etc/ssh/sshd_config
Then
Code: Select all
sudo nano /etc/motd.tcl
add the following ugly but functional code
Code: Select all
#!/usr/bin/env tclsh
# MOTD script original? / mod mewbies.com

# * Variables
set var(user) $env(USER)
set var(path) $env(PWD)
set var(home) $env(HOME)

# * Check if we're somewhere in /home
#if {![string match -nocase "/home*" $var(path)]} {
if {![string match -nocase "/home*" $var(path)] && ![string match -nocase "/usr/home*" $var(path)] } {
  return 0
}

# * Calculate last login
set lastlog [exec -- lastlog -u $var(user)]
set ll(1)  [lindex $lastlog 7]
set ll(2)  [lindex $lastlog 8]
set ll(3)  [lindex $lastlog 9]
set ll(4)  [lindex $lastlog 10]
set ll(5)  [lindex $lastlog 6]

# * Calculate current system uptime
set uptime    [exec -- /usr/bin/cut -d. -f1 /proc/uptime]
set up(days)  [expr {$uptime/60/60/24}]
set up(hours) [expr {$uptime/60/60%24}]
set up(mins)  [expr {$uptime/60%60}]
set up(secs)  [expr {$uptime%60}]

# * Calculate usage of home directory
set usage [lindex [exec -- /usr/bin/du -ms $var(home)] 0]

# * Calculate SSH logins:
set logins    [lindex [exec -- who -q | cut -c "9-11"] 0]

# * Calculate processes
set psu [lindex [exec -- ps U $var(user) h | wc -l] 0]
set psa [lindex [exec -- ps -A h | wc -l] 0]

# * Calculate current system load
set loadavg     [exec -- /bin/cat /proc/loadavg]
set sysload(1)  [lindex $loadavg 0]
set sysload(5)  [lindex $loadavg 1]
set sysload(15) [lindex $loadavg 2]

# * Calculate Memory
set memory  [exec -- free -m]
set mem(t)  [lindex $memory 7]
set mem(u)  [lindex $memory 8]
set mem(f)  [lindex $memory 9]
set mem(c)  [lindex $memory 16]
set mem(s)  [lindex $memory 19]


# * ascii berry
set head {          .~ .~~~..~.                      _                          _
         : .~.'~'.~. :     ___ ___ ___ ___| |_ ___ ___ ___ _ _    ___|_|
        ~ (   ) (   ) ~   |  _| .'|_ -| . | . | -_|  _|  _| | |  | . | |
       ( : '~'.~.'~' : )  |_| |__,|___|  _|___|___|_| |_| |_  |  |  _|_|
        ~ .~ (   ) ~. ~               |_|                 |___|  |_|   
         (  : '~' :  )
          '~ .~~~. ~'
              '~'}
# * ascii leaf
set head2 {
          .~~.   .~~.
         '. \ ' ' / .'}
# * display kernel version
set uname [exec -- /bin/uname -snrvm]
set unameoutput0 [lindex $uname 0]
set unameoutput [lindex $uname 1]
set unameoutput2 [lindex $uname 2]
set unameoutput3 [lindex $uname 3]
set unameoutput4 [lindex $uname 4]
# * display temperature
set temp [exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"]
set tempoutput [lindex $temp 0]
# * display GPU version
set gpu [exec -- /opt/vc/bin/vcgencmd version]
set gpuoutput [lindex $gpu 0]
set gpuoutput1 [lindex $gpu 1]
set gpuoutput2 [lindex $gpu 2]
set gpuoutput3 [lindex $gpu 8]
set gpuoutput4 [lindex $gpu 9]

# * Print Results
puts "\033\[01;32m$head2\033\[0m"
puts "\033\[02;31m$head\033\[0m"
puts "   System........: $unameoutput0 $unameoutput $unameoutput2 $unameoutput3 $unameoutput4"
puts "   GPU Version...: $gpuoutput $gpuoutput1 $gpuoutput2, $gpuoutput3 $gpuoutput4"
puts "   Last Login....: $ll(1) $ll(2) $ll(3) $ll(4) from $ll(5)"
puts "   Uptime........: $up(days)days $up(hours)hours $up(mins)minutes $up(secs)seconds"
puts "   Temperature...: $tempoutput°C"
puts "   Load..........: $sysload(1) (1minute) $sysload(5) (5minutes) $sysload(15) (15minutes)"
puts "   Memory MB.....: Total: $mem(t)  Used: $mem(u)  Free: $mem(f)  Cached: $mem(c)  Swap: $mem(s)"
puts "   Disk Usage....: You're using ${usage}MB in $var(home)"
puts "   SSH Logins....: Currently $logins user(s) logged in."
puts "   Processes.....: You're running ${psu} which makes a total of ${psa} running"

if {[file exists /etc/changelog]&&[file readable /etc/changelog]} {
  puts " . .. More or less important system informations:\n"
  set fp [open /etc/changelog]
  while {-1!=[gets $fp line]} {
    puts "  ..) $line"
  }
  close $fp
  puts ""
}
Make the script executable
Code: Select all
sudo chmod 755 /etc/motd.tcl
and add
Code: Select all
/etc/motd.tcl
to the end of the file
Code: Select all
/etc/profile


The ascii art is made by user piksel and was taken from the link in the initial post.

ssh_login.jpg
ssh_login.jpg (23.3 KiB) Viewed 31242 times
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by haincha » Fri Nov 30, 2012 5:33 pm
I found all of your information really helpful. I have one question, though. I went a little above and beyond on the formatting. Is there any way to have items that need multiple lines retain formatting? Confusing... I know, so a picture! :)

Notice how the A: is way to the left? Is it possible to get that second line of text to start under the beginning of the first line?
Attachments
raspi.PNG
raspi.PNG (19.44 KiB) Viewed 31180 times
Posts: 16
Joined: Tue Sep 25, 2012 11:53 pm
by mparrott82 » Sun Dec 02, 2012 2:16 pm
azeam, when I use you method and code I get the following error when logging on. Any ideas? i am not a tclsh programmer.

wrong # args: should be "set varName ?newValue?"
while executing
"set uptime    [exec -- /usr/bin/cut -d. -f1 /proc/uptime]"
(file "/etc/motd.tcl" line 24)
pi@raspberrypi ~ $
Posts: 16
Joined: Wed Aug 29, 2012 10:12 pm
by azeam » Fri Dec 07, 2012 12:14 pm
haincha wrote:Is it possible to get that second line of text to start under the beginning of the first line?

The easiest way is probably to put the second line on a separate line in the code (puts) and use spaces to get it where you want it.

mparrott82 wrote:azeam, when I use you method and code I get the following error when logging on.

Are you sure that you pasted exactly the code above? Have you made any other changes to it?

Here is a better (I think) disk space code, note that the numbers might be different depending on whether you use external drives or not.
Code: Select all
set disk [exec -- /bin/df -h]
set disksize [lindex $disk 8]
set diskused [lindex $disk 9]
set diskpercent [lindex $disk 11]
set diskextern [lindex $disk 52]

puts "   Disk Usage....: You're using $diskused of $disksize ($diskpercent), ($diskextern available on Extern)"
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by zakret » Fri Dec 07, 2012 12:57 pm
Hi

I modified this script and moved all what takes too long to cron. Now cron saves results (example weather) in file every hour and during login script reads this from file. It's faster.

Best regards
TZ
Posts: 2
Joined: Mon Nov 12, 2012 7:46 am
by startreksteve » Fri Dec 07, 2012 2:43 pm
zakret wrote:Hi

I modified this script and moved all what takes too long to cron. Now cron saves results (example weather) in file every hour and during login script reads this from file. It's faster.

Best regards
TZ


Excellent!
Would you care to share your crontab with us?
Posts: 43
Joined: Tue Mar 13, 2012 10:23 am
by zakret » Sat Dec 08, 2012 11:07 am
startreksteve wrote:
zakret wrote:Hi

I modified this script and moved all what takes too long to cron. Now cron saves results (example weather) in file every hour and during login script reads this from file. It's faster.

Best regards
TZ


Excellent!
Would you care to share your crontab with us?


Yes, sure.

current_ip file with +x attribute in /etc/cron.daily
Code: Select all
#!/bin/sh

IP_WEWN=`/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1`
IP_ZEWN=`wget -q -O - http://icanhazip.com/ | tail`
echo $IP_WEWN and $IP_ZEWN > /etc/script-results/ip


current_temp file with +x attribute in /etc/cron.hourly
current_temp saves weather results and also time and date to separated file.
Weather is for Wroclaw in Poland
Code: Select all
#!/bin/sh
TODAY=`date +"%A, %e %B %Y, %R"`
TEMP=`curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|PL|PL001|WROCLAW|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`

echo $TEMP > /etc/script-results/weather_wroclaw
echo $TODAY > /etc/script-results/weather_date


and finally my /etc/profile code
Code: Select all
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`

# get the load averages
read one five fifteen rest < /proc/loadavg

echo "$(tput setaf 2)
   .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
  '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
   .~ .~~~..~.   
  : .~.'~'.~. :   Uptime.............: ${UPTIME}
 ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
 ~ .~ (   ) ~. ~  Running Processes..: `ps ax | wc -l | tr -d " "`
  (  : '~' :  )   IP Addresses.......: `cat /etc/script-results/ip`
   '~ .~~~. ~'    Weather in Wroclaw.: `cat /etc/script-results/weather_wroclaw`
       '~'        Weather at.........: `cat /etc/script-results/weather_date`
$(tput sgr0)"
Posts: 2
Joined: Mon Nov 12, 2012 7:46 am
by Igneosaur » Thu Dec 20, 2012 8:21 pm
It's been a while since I played around with my pi and I had coloured promts set up, but after I created a .bash_profile and put this script in, I've lost my coloured prompt. I don't really get what's going on here, could anyone here fill me in?
Posts: 3
Joined: Fri Aug 10, 2012 1:27 pm
by skiwithpete » Sun Dec 23, 2012 1:35 am
here's my customized version with coloured prompts, temperature, 2 external HDDs and weather for Auckland.

Code: Select all
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  # We have color support; assume it's compliant with Ecma-48
  # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  # a case would tend to support setf rather than setaf.)
  color_prompt=yes
    else
  color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`

# get the load averages
read one five fifteen rest < /proc/loadavg

echo "$(tput setaf 2)
   .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
  '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
   .~ .~~~..~.
  : .~.'~'.~. :   Uptime.............: ${UPTIME}
 ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
( : '~'.~.'~' : ) CPU Temperature....: `exec -- /opt/vc/bin/vcgencmd measure_temp | cut -c "6-9"`
 ~ .~ (   ) ~. ~  Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
  (  : '~' :  )   Running Processes..: `ps ax | wc -l | tr -d " "`
   '~ .~~~. ~'    IP Addresses.......: `/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1` and `wget -q -O - http://icanhazip.com/ | tail`
       '~'        Auckland Weather...: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=OCN|NZ|NZ000|AUCKLAND" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
                  Free Disk Space SD.: `df -Pk | grep -E '^/root/' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /root
                  Free Disk Space 4tb: `df -Pk | grep -E '^/dev/sda1' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /dev/sda1 -- `df -Pk | grep -E '^/dev/sda1' | awk '{ print $5 }' | awk -F '.' '{ print $1 }'` of capacity
                  Free Disk Space 2tb: `df -Pk | grep -E '^/dev/sdb1' | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`k on /dev/sdb1 -- `df -Pk | grep -E '^/dev/sdb1' | awk '{ print $5 }' | awk -F '.' '{ print $1 }'` of capacity                                   

$(tput sgr0)"
Posts: 8
Joined: Sun Sep 25, 2011 8:09 am
by icedragon » Fri Dec 28, 2012 4:40 am
So,

I was driving myself crazy trying to find a solution to the Weather for us here in the USA. Turns out it was so simple I feel like smacking my head against the wall. Yes, there are codes for the accuweather that someone posted in an earlier post but these do not work for the USA.

All you need to do is replace the coding at the end like so...

For Europe:
"http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|"

For USA:
"http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=*Your Zip Code*

Make sure you remove the *'s on both sides of the Zip.

Anyway hope this helps!
Posts: 1
Joined: Fri Dec 28, 2012 4:20 am
by soundsk » Thu Jan 10, 2013 10:57 am
Hi!

Tried to get this working for me, but when I try to run the script by I get:
Code: Select all
let: not found
on line 3.
It is referring to the first line of actual code:
Code: Select all
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"

If I run the cut command like stated above it works, so it's not that, "let" is also available so I can't figure out what's wrong. Any hints?

Thanks! Cheers!
Posts: 4
Joined: Fri Dec 28, 2012 1:47 pm
by soundsk » Thu Jan 10, 2013 2:38 pm
Got it!
Was using
Code: Select all
#!/bin/sh
, changed to
Code: Select all
#!/bin/bash
and all is good!

Cheers!
Posts: 4
Joined: Fri Dec 28, 2012 1:47 pm