Sunday, October 30, 2016

Bash Programs, Task Scheduler, and Random Quote Notes

This is a brief extension to my last post with some implementation notes.

First of all, I use my flash drives mounted on my PCs to store certain portable or near-portable applications, including a launcher I've described in the past, Quick Cliq. It's fairly easy to build folders of applications and utilities in Quick Cliq. I can use a utility like Voidtools' Everything Search to quickly locate desired executables and drag/drop the executable to the command region of a new menu item. It's also easy to build a Microsoft utility folder. The command region has a set utility pull down region, with a System Shortcut option (about halfway down). Then you can pick and choose your key utilities through a pop-up selection, e.g., computer management, add or remove programs, services, and task scheduler. (Note that you can also script elevated privileges, e.g., on CMD prompt, by prefacing the command with RUNAS.)

To be honest, I never played much with Microsoft's Task Scheduler. I ran into puzzling issues in trying to schedule a Bash script as described in the last post. (By the way, it's not necessary to use the -c option.) Also, one of my licensed security software products identified my batch cover file for a Bash script as "malware" and expunged it from my system. Basically, I specify bash as the command and then type the Unix-style full path to the shell script in the parameter box, e.g., "/mnt/c/Users/Ro..../.../newquote.sh"  (note that there are sometimes issues with embedded spaces,  as in "Ronald Guillemette", so I'll typically include the fully qualified file name in double-quotes). After I created the task (with repeated intervals), I could run it manually from the scheduler, and it seemed to indicate an expected next scheduled run-time but didn't seem to launch at that time. It may have been one of those quirks which can be resolved by a PC reboot. However, I decided to use the system startup event option for the defined task and rebooted; the script is running without issue at expected intervals.

One of my gripes about the gmail signature feature is that I've got to change the signature manually.through settings. This is unlike the Mozilla Thunderbird client which more conveniently allows me to attach a (fixed) html page as the signature, e.g., newquote.htm, which my homegrown Bash script yields. I would obviously prefer functionality that doesn't require changing settings to generate an updated quote signature. However, there are ways to make the manual setting easier, e.g., launch the html file into one's browser and save it as a bookmark. Then copy and paste from your browser tab/page into the gmail signature block.

Finally, one can easily generate the html code needed for the formatted signature page through a full-fledged word processing program, like industry-standard Microsoft Word.  I then use Notepad++, a freeware text/programming editor, which reads and writes html code, to splice the code segments sandwiching the randomly selected quote in my shell script. I also use Notepad++ to modify my text quote file (one quote per line).