I'm using python scripts to create my MOTD in Ubuntu Server 18.04. I found this problem when trying to display the temps of my hard drives. I wanted to display the temperature using the degree symbol as such ##°C
, but the output wouldn't show when I logged in to the server.
Removing the degree symbol fixed the problem.
Example code
#!/usr/bin/python3
print(u"\u00B0" + "C")
print("°C")
print('°' + "C")
print('\u00B0' + "C")
File was saved as 00-testpython
, and running the script from the command line outputs as expected:
$ ./00-testpython
°C
°C
°C
°C
Running the scripts with run-parts
returns the expected response:
$ run-parts --lsbsysinit /etc/update-motd.d
°C
°C
°C
°C
Logging in with ssh displays whatever was in the old /run/motd.dynamic
, and does not update with the expected MOTD.
I have a strong feeling that this has something to do with encoding, but I'm not sure what it would be. Printing from python can use ANSI escape characters to print in color; I'm not sure why this is causing an issue.
Using a bash script to echo the degree symbol works fine:
#!/bin/sh
echo °