Tuesday, November 17, 2020

Here are a few customizations to my CYGWIN GNU COBOL setup.

I have just finished a 4 year project and have slowed down to site maintenance for the moment at the University. Now it is time to start contributing to my Blog. Thank you for visiting my Blog. Here at the University of Tennesee we tend to brand everything we have. That being said I like to customize my environments that I use. There are many options in CYGWIN that many people may not know about.

Jay Summet has a great CYGWIN Install video check out this link:

https://www.youtube.com/watch?v=st8rjU0h0JM



First, I have a custom screen that comes up when I launch the CYGWIN console. The message is just a shell script that prints up the message for the user to see when the window is opened.

This is easily done by adding one line to the ‘.profile’ file in your home directory.

./message.sh

You can do a PWD after opening your CYGWIN console, or just type ‘echo $HOME’.

 So your $HOME will be ‘/home/{user name} ‘ but the real path in windows will be something like the following ‘C:\cygwin64\home\{user name}’.

The content for ‘message.sh’ is as follows:

#!/bin/bash

# This script clears the terminal, displays a greeting and gives information

# about currently connected users.  The two example variables are set and displayed.

clear # Clear the terminal window.

echo "                 * * * * * * * W A R N I N G * * * * * * * * * *"

echo " "

echo "This computer system is the property of the {organization name}. It is for  authorized use only. Unauthorized or improper use of this system may result in  administrative disciplinary action and/or civil charges/criminal penalties. By  continuing to use this system you indicate your awareness of and consent to     these terms and conditions of use."

echo " "

echo "LOG OFF IMMEDIATELY if you do not agree to conditions stated in this warning."

echo " "

echo "                 * * * * * * * * * * * * * * * * * * * * * * * * "

echo "Welcome, $USER" # dollar sign is used to get content of variable.

echo "Today's date is `date`, this is week `date +"%V"`."

echo "These users are currently connected:"

who | cut -d " " -f 1 - | grep -v USER | sort -u

echo " "

echo "This is `uname -s` running on a `uname -m` processor."

echo " "

#echo "This is the uptime information:"

#uptime

echo

 

The script also displays the User ID, time, date, and uptime.

I also have a menu that is custom made to run my favorite programs.

Menu content {menu.sh} is as follows:

#!/bin/bash

 

function press_enter

{

    echo ""

    echo -n "Press Enter to continue"

    read

    clear

}

 

function today {

    echo "Today's date is: "

    date +"%A, %B %-d, %Y"

}

 

 

selection=

until [ "$selection" = "0" ]; do

    clear

    echo ""

    echo "COMMAND LINE MENU"

    echo "    ---------------------------"

    echo "1   - display free disk space"

    echo "2   - display free memory"

    echo "3   - display current date"

    echo "4   - display processes"

    echo "5   - Shut Down SSH Service"

    echo "6   - Start Up  SSH Service"

    echo "7   - other programs"

    echo "8   - Phone Numbers"

    echo "8.5 - Do not select this!"

    echo "9   - Password Database"

    echo "    ----------------------------"

    echo "0   - exit menu"

    echo ""

    echo -n "Enter selection: "

    read selection

    echo ""

    case $selection in

        1 ) df ; press_enter ;;

        2 ) free ; press_enter ;;

        3 ) today ; press_enter ;;

                4 ) ps -ef; press_enter;;

                5 ) net stop sshd; press_enter;;

                6 ) net start sshd; press_enter;;

                7 ) games;;

        8 ) utkphonwin ;;

                8.5 ) phbook ;;

        9 ) COB_PRE_LOAD=cobdes utpasssecwin ;;

        0 ) exit ;;

        * ) echo "Please enter 1, 2, or 0"; press_enter

    esac

 

done

 

I would like to mention you can use the .profile to automatically launch the menu to create a ‘turn key’ system.

Thanks for visiting my Blog and I hope to have new content soon.



1 comment:

  1. You can find the source on GITHUB

    https://github.com/jfarrell423/cygwin-cbl

    ReplyDelete