Paul Sutton

scripting

Networking and SSh

I have decided to republish these links as there are a few people on the Fediverse who work or are involved in InfoSec and CyberSecurity.

These videos are a starting point for understanding networking and also SSH which allows remote login to remote computer.

So next up are the links to the videos on Networking and another video on OpenSSH (SSH being Secure SHell of course.

I am reposting links to previous blog posts that looked at these topics:-

I can be contacted on Fediverse / mastodon, search for @zleap@qoto.org.

TAGS

#GNULinux,#Shell,#Bash,#Scripting,#Nano,#Editor,#InfoSec,#Cybersecurity,#CodeClub,#PaigntonLibrarySTEMGroup


MastodonPeertubeQoto sign up

Donate using Liberapay

NANO and Shell scripting

I have decided to republish these links as there are a few people on the Fediverse who work or are involved in InfoSec and CyberSecurity. These videos are a starting point as it is very useful to understand how to use the GNU/Linux command line along with related tools in general.

You may find the links on the BASH Basics post useful

I am reposting links to previous blog posts that looked at these topics:-

I can be contacted on Fediverse / mastodon, search for @zleap@qoto.org.

TAGS

#GNULinux,#Shell,#Bash,#Scripting,#Nano,#Editor,#InfoSec,#Cybersecurity,#Video,#CodeClub,#PaigntonLibrarySTEMGroup


MastodonPeertubeQoto sign up

Donate using Liberapay

FSF Workshops

The first of the post LibrePlanet workshops takes place on Monday 10th April. Details below.

Newk Script: Code katas to learn programming

  • Time: Monday, April 10, 12:00–13:30 EDT (16:00–17:30 UTC)
  • Format: Online workshop
  • Event link
  • Registration link
  • Presenter: Reynaldo Cordero
  • Description:
Are you interested in a serendipitous Haskell programming learning method on your computer with over 1,700 katas ready to train? Newk is a Bash script using a 100% free software environment that takes advantage of serendipity the same way you learn to speak in childhood. No formal (or informal) classes: you are simply exposed to spoken information of any kind and at any level in real contexts, where everything is new, surprising, and true. Did you learn to speak? You will learn to program!

Links

Tags

#FSF,#Workshops,#Coding,#Scripting


MastodonPeertubeQoto sign up

Donate using Liberapay

CyberSecurity part 12

So we are on part 12, well done and thank you to everyone who has stuck with this so far. Today I am linking to s shell scripting crass course.

Joe Collins who presented the bash videos earlier also has a series of videos on shell scripting

Useful stuff

If you write a bash script, that needs the user to run as with elevated privileges this code may be handy.

if [ "$EUID" -ne 0 ]
  then echo "Please run as root / sudo"
exit

  else

Links

Tags

#CyberSecurity,#Shell,#Scripting


MastodonPeertubeQoto sign up

Donate using Liberapay

Ansi Weather

Donate using Liberapay

Getting weather information is really useful. What happens if you're at the command line in Linux? I found a really little application that can help

ansiweather

apt install ansiweather

ansiweather -l Plymouth, UK

Ansi Weather Output

So what else can we do with this

  1. Send the output to Mastodon with toot post

This is a two step process

  1. ansiweather -l Plymouth, UK > weather.txt
  2. toot post < weather.txt

Will send the weather info to Mastodon.

However this does not include any date info

We can fix this with

  1. date > weatherinfo.txt
  2. ansiweather -l Plymouth, UK >> weatherinfo.txt

then send the whole lot to Mastodon with

  1. toot post < weatherinfo.txt

So, if we put this in to a final shell script we need:-

#send weather info to Mastodon
# current date
date > weatherinfo.txt
# current weather
ansiweather -l Plymouth, UK >> weatherinfo.txt
#send to Mastodon
toot post < weatherinfo.txt
# done
echo done

Again released under GPLv3

I tried to get festival to speak the weather, it is not perfect but this sort of works, you will need to direct to weather.txt first.

festival —tts < weather.txt

Looking in to this further, the issue is the brackets etc, so this stackoverflow post

strips out the colour formatting

sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt

Therefore

sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt

Sends the newly formatted text to weatherinfo2.txt

So running back through festival

festival —tts < weather.txt

Is perhaps a little better, but not perfect

So going back to what we wrote earlier to send to Mastodon, the new script

  1 #send weather info to Mastodon
  2 # current date
  3 date > weatherinfo.txt
  4 # current weather
  5 ansiweather -l Plymouth, UK >> weatherinfo.txt
  6 # clean up output with sed
  7 sed 's/\x1b\[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt
  8 #send to Mastodon
  9 toot post < weatherinfo2.txt
 10 # done
 11 echo done

Produces much nicer output. The top bottom part of this illustrates what was sent before we stripped out the colour formatting

However it still isn't perfect, as it removes part some of the wording, but it is hopefully getting there.

Weather Output (new)

REFERENCES

TAGS

#YearOfTheFediverse,#Weather,#Scripting,#Bash,#Linux, #Mastodon,#ProblemSolving,#AnsiWeather,#programming, #Stackoverflow,#sed,#cat,#grep,GPL3,#FSF

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License


MastodonPeertubeQoto sign up

Donate using Liberapay

Script for $\LaTeX$ Tables

I was asked in irc ( ##chemistry on frenode) about a project to create a table for periodic table data in $\LaTeX$.

This post, is meant to be a rough guide. You are expected to do your own research in to any specific features you need.

As there are now about 120 elements, doing this manually could be rather long winded. So I am trying to develop a small shell script to help with this process.

Firstly Looking at loops in Bash

now how to generate a basic table in $\LaTeX$

\begin{table}[]
\begin{tabular}{llllll}
 &  &  &  &  & 
\end{tabular}
\caption{}
\label{tab:my-table}
\end{table}

This is for a 1 row table, to add multiple rows, you need to add \ at the end of the row as in:-

\begin{table}[]
\begin{tabular}{llllll}
 
 &  &  &  &  &  \\
 &  &  &  &  &  \\
 &  &  &  &  & 
\end{tabular}
\caption{}
\label{tab:my-table}
\end{table}

The following shell script should help us with this.

Please note that the \, should be removed from the very last row.

I have added a script for 10 rows. This can be changed via the shell script.

 1 #!/bin/bash
  2 
  3 echo " " > data.txt
  4 echo "\begin{table}[]" > data.txt
  5 echo "\begin{tabular}{llllll}" >> data.txt
  6 #wc -l data.txt
  7 
  8 for i in {1..10..1}
  9   do 
 10 
 11      #echo "hello"
 12      echo  "&  &  &  &  & \\" >> data.txt
 13  done
 14 #wc -l data.txt
 15  echo  "\end{tabular}" >> data.txt
 16  echo  "\caption{}" >> data.txt
 17  echo  "\label{tab:my-table}" >> data.txt
 18  echo  "\end{table}" >> data.txt

Required table headings were : atom ; r atomic ; density ; Tf ; Tg ;... ?

Table headings are obviously at the top, therefore, once you have run the script and generated the right number of rows amending the first row to

& atom & r atomic & density & Tf & Tg \

Should give the required headings

I have added some word count (wc) to help with diagnostics.

You will need to change the output file extension to .tex for a $\LaTeX$ file. I'll leave it as data.txt as you need to add the other components of a $\LaTeX$ document anyway.

If the table spans more than 1 page then the table should use

\begin{longtable}{llllll}
\end{longtable}

#chemistry, #typesetting, #bash, #LaTeX, #tables, #scripting

You can find me on Friendica at zleap@social.isurf.ca


MastodonPeertubeQoto sign up

Donate using Liberapay