2022年10月30日 星期日

To send colon in script using msmtp

In an project of building a file server for a small office and which should be able to access outside the office via Internet. The office did not have a public IP. It was decided to setup a nextcloud server together with a samba server and send the dynamic public IP obtained from the ISP to related staff in a email each time it started.

Msmtp was installed and configured properly for sending the required email in a script. The simple email just consisted of the subject and the IP as the body. The command is 

printf "Subject: NextCloud Server New IP\n${myip}" | msmtp xxx@gmail.com

It worked. In order to improve the performance, it would be better to send a link to the server rather than the IP itself. So, the command was modified to

printf "Subject: NextCloud Server New IP\nhttps://${myip}" | msmtp xxx@gmail.com

Here came the problem, the email had still to be send, but nothing in the body. There seemed do not have any syntax error. The printf function prints exactly what is needed. The problem should be on msmtp.

Google the great came to help. Not many articles related were suggested from Google. Colon cannot be send with msmtp is still an open question. Some suggested to prepare a text file for the email first and then send the text file with msmtp. So, text files were prepared and it worked once and only once. It was rather strange. After trying to make it work again, many many times, one noticed that at the time it worked, the text file was copied from somewhere and consisted many blank lines before the body text. So several blank was then inserted before the https: and tried again. It worked and could be duplicated. The final command is

printf "Subject: NextCloud Server New IP\n\n\n\n\n\nhttps://${myip}" | msmtp xxx@gmail.com

No attempt was made to see at least how many blank lines are needed. At least it worked for what was needed. 

The conclusion is that msmtp uses blank lines to distinguish the header and the body of an email. If the colon is inside the body, it will be handled properly.

2022年10月10日 星期一

 To cheat hp-plugin

Enjoyed the use of Zorin 15 for quite a long time, Zorin 16 had come out recently. To update the system in use to the new Zorin release and to get rid of the damaged hard disk housing the OS. I made up my mind to have a clean new installation of the new Zorin release in a new SSD. 

It was easy to set up the new system and everything seemed to be OK. It was the HP all-in-one printer that cause the problem. The printer functioned good, but the scanner did not function. Whenever a software wanted to make a scan, a hpaio I/O error with the scanner was reported. I did not have any hints on what was happening. Of course, Google is the place for me to ask for a solution. After reading a lot form those related articles, I concluded that I had to re-install hplip and run hp-plugin. When I ran hp-plugin, it needed to download the plugin. It said the plugin downloaded was corrupted and quitted. So, I got the plugin from the net and gave the path to hp-plugin. It said Zorin is not an approved OS and quitted. I asked it to select the OS as others. That is Ubuntu, the ancestor of Zorin.  It went ahead and then told me that a lot of dependencies were not available and asked me to install them manually. OMG, what a tedious works. I tried, but some of them are not available from the depositories. Ther was no way to solve the problem, all failed, I thought.

After a long time of thinking about the matter, I decided to cheat the program hp-plugin. I got a copy of the os-release file from an Ubuntu machine to replace that of the Zorin machine. Then run hp-plugin again, it worked. The plugin was installed successfully and the scanner can then be work properly.

Sometimes, a trick can help you work around and save a lot of times.  

2022年10月8日 星期六

Reformation of the mathematics resources section

Building up of the mathematics resources section had been stopped for a long long time. It is because of I do not had solutions or answers of some worksheets, test papers and examination papers  and I do not have times and energy to make them up.

As recently, I found there are needs of these materials for the fact that the section was visited sometimes. So I make up my mind to post all my worksheets and test/exam papers collection again to pay a little effort to mathematics educations. 

As a matter of fact, almost all these materials were collected from various sources from the Internet and these materials were used in my worksheets according to the fair use principle. If any of the materials offended you right, please let me know and I should take it away from the section ASAP.

As solutions and answers were not available for worksheets, test /examination papers, I would be very happy to see someone would share theirs with others.

Let make mathematics learning a fun!