info.sh

By Aha2Y on Sep 02, 2011

This is my first bash script. This is a bash script which shows you some useful information.

Menu [1] Show Todays date/time [2] Shows directory [3] Show system uptime [4] Show system info [5] Show account info [6] Show online users [7] Exit the menu

- Status - This snippet is finished.

#!/bin/bash

while :
 do
    clear
    echo "-------------------------------------"
    echo " info.sh - Main Menu - By Aha2Y "
    echo "-------------------------------------"
    echo "[1] Show Todays date/time"
    echo "[2] Shows directory"
    echo "[3] Show system uptime"
    echo "[4] Show system info"
    echo "[5] Show account info"
    echo "[6] Show online users"
    echo "[7] Exit/Stop"
    echo "======================="
    echo "" 
    echo -n "Enter your menu choice [1-7]: "
    read input
    case $input in
    1) 
    echo "Today is `date` , press a key. . ." ; read ;;
    2) 
    echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;
    3) 
    uptime ; echo "Press a key. . ." ; read ;;
    4) 
    FILE=sysinfo.pl
    if [ -f $FILE ]; then
    perl sysinfo.pl ;
    else 
    wget http://kottnet.net/sysinfo.pl && perl sysinfo.pl ;
    fi ; read ;;
    5) echo "" 
    echo "--------------------------"
    echo "User: $USER" ; 
    echo "Home: $HOME" ; 
    if [ $USER == "root" ] ; then
    echo "Root: yes" ;
    else
    echo "Root: no"
    fi ;
    echo "OsType: $OSTYPE"
    echo "--------------------------" 
    echo ""
    echo "press a key. . ." ; read ;;
    5) w ; read ;;
    6) exit 0 ;;

    *) echo "Please select a number.";
    esac
    done

Comments

Sign in to comment.
Frenetic   -  Sep 07, 2011
echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;

you should use -la, to list hidden ones as-well.

More
 Respond  
Hawkee   -  Sep 02, 2011

All the info you need is right on Google, http://www.google.com/search?q=bash+command+line+argument

More
 Respond  
Aha2Y   -  Sep 02, 2011

Hawkee, could you tell me how to do that? or link to a tutorial for that?

More
 Respond  
Hawkee   -  Sep 02, 2011

Not bad, but you shouldn't do a continuous loop. Just take the number from the command line and display the help screen when requested. For example:

info.sh 2 info.sh --help info.sh h

More
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.