Trying the code syntax highlighting

Bash

Some snippets of different language coding to see how the syntax highlights work

#!/bin/bash
#

# The NAS1 destination is a share called  Backups
# which is accessed via "daemon rsync" at nas1::Backups
# rather than a directory in /home/g4slv
# this allows passwordless rsync. Necessary since the ssh
# server @ nas1 is too old to accept identity keys from
# modern ssh clients - so normal rsync-over-ssh would require
# a password.
#
# Using a "module" overcomes this, and allows for automatic
# backups.
#


EXCLUDEFROM=~/exclude
SOURCE=/home/g4slv/

DEST=devuan
WIKI=wiki
#CLOUD=217.154.53.244
CLOUD=g4slv.info

# Test if the destinations are reachable
NAS=` ping -c 1 -w 1 192.168.21.5 | grep received | awk '{print $4}'`
LAPTOP=` ping -c 1 -w 1 192.168.21.101 | grep received | awk '{print $4}'`
INFO=` ping -c 1 -w 1 $CLOUD | grep received | awk '{print $4}'`

if [ $NAS == 1 ]
then
    rsync -av --delete /var/www/html/ 192.168.21.5::Backups/$WIKI
    rsync -av  --exclude-from=$EXCLUDEFROM $SOURCE 192.168.21.5::Backups/$DEST
else
    echo "NAS1 not found"
fi

if [ $LAPTOP == 1 ]
then
    rsync -av --delete /var/www/html/ 192.168.21.101:backups/$WIKI
    rsync -av --exclude-from=$EXCLUDEFROM $SOURCE 192.168.21.101:backups/$DEST
else
    echo "Laptop not found"
fi

if [ $INFO == 1 ]
then
rsync -av -e 'ssh -p 2182' --exclude-from=$EXCLUDEFROM $SOURCE $CLOUD:backups/$DEST
else
    echo "Server INFO not found"
fi

~    

Python


#!/usr/bin/env python
# -*- coding: Latin-1 -*-
# test UDP Client for YaDD UDP
import socket
#import sys

import time


HOST, PORT1, PORT2 = "172.245.94.61", 50666, 4530

data1 = "[W2WTEST];2187.5;SEL;247437900;SAF;247437900;TEST;NOINF;--;--;REQ;OK"
data2 = "W2WTEST1 1.7;002111240;(safety);from;253726000; test REQ;25-04-21 17:42:51;"
data3 = "[W2WTEST2];12577.0;SEL;002320204;SAF;002320010;TEST;NOINF;--;--;REQ;OK"
data4 = "[W2WTEST3];2187.5;SEL;002320204;SAF;002320009;TEST;NOINF;--;--;REQ;OK"


sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)



sock.sendto(data1, (HOST, PORT1))

time.sleep(1)

sock.sendto(data2, (HOST, PORT2))

C

#include <stdio.h>

int main()
{

        int pound;

        int twenty;
        int ten;
        int five;
        int one;

        printf("Enter an amount of pounds : ");
        scanf("%d", &pound);
        
        twenty = pound / 20;
        pound = pound - (twenty * 20);

        ten = pound / 10;
        pound = pound - (ten * 10);

        five = pound / 5;
        pound = pound - (five * 5);

        one = pound;

        printf("£20 : %d\n", twenty);
        printf("£10 : %d\n", ten);
        printf("£5  : %d\n", five);
        printf("£1  : %d\n", one);



        return(0);
}