When I run this PowerShell script:
https://github.com/dharmatech/net-liquidity.ps1
the output looks as follows:
In order to share the results with others, I convert the output to HTML. The resulting page looks like this:
Here's a link to that page:
https://dharmatech.dev/data/reports/net-liquidity-table.html
Here's how the HTML is generated.
Here is cron.sh
. It takes case of running the to-html.sh
script inside screen (to provide a terminal to the underlying process):
#!/bin/sh
cd /var/www/dharmatech.dev/data/net-liquidity.ps1
screen -d -m ./to-html.sh
Here is to-html.sh
:
#!/bin/sh
cd /var/www/dharmatech.dev/data/net-liquidity.ps1
script -q -c 'pwsh -Command ./net-liquidity-earnings-remittances.ps1 -display_chart_url -save_iframe' script-out-nl
cat script-out-nl |
/home/dharmatech/go/bin/terminal-to-html -preview |
sed 's/pre-wrap/pre/' |
sed 's/terminal-to-html Preview/Net Liquidity Table/' |
sed 's/<body>/<body style="width: fit-content;">/' > ../reports/net-liquidity-table.html
mv net-liquidity-chart.html ../reports
mv spx-fair-value-chart.html ../reports
It does the following:
- The
script
utility is used to call thenet-liquidity.ps1
script.script
captures all the output (including color escape codes) and saves it to a file- https://manpages.debian.org/testing/bsdutils/script.1.en.html
- This file is then send through
terminal-to-html
sed
is used to adjust the resulting HTML
This script is to run Mon-Fri at 10:20 eastern and 1:05 PM eastern. It should also run on Thur at 1:45 PM eastern. Here are the crontab entries for this:
20 10 * * MON-FRI /var/www/dharmatech.dev/data/net-liquidity.ps1/cron.sh
5 13 * * MON-FRI /var/www/dharmatech.dev/data/net-liquidity.ps1/cron.sh
45 13 * * THU /var/www/dharmatech.dev/data/net-liquidity.ps1/cron.sh
Here's a short video walking through some of this.