CN5103 Operating Systems Assignment: Windows and Unix Scripts
VerifiedAdded on  2023/05/28
|9
|1488
|371
Practical Assignment
AI Summary
This report presents a practical assignment focused on operating systems, specifically the creation of scripts for both Windows and Unix environments. The assignment involved developing batch files for Windows and shell scripts for Unix (Knoppix 8.1, using VMWare) to perform system administration tasks. The Windows script, written in a .bat file, utilizes commands to display running processes, logged-in users, plugged-in devices, disk usage, and system information, including the deletion of temporary files. The Unix script, written in bash, achieves similar objectives, displaying current processes, logged-in users, device information, disk usage, network interface status, RAM usage, and operating system version. The report details the scripting process, syntax differences, and the use of commands like `tasklist`, `wmic`, `ps`, `who`, `ls`, `du`, and `ip`. The outputs of the scripts are stored in text files for analysis. The report includes a discussion on the development process, the importance of system resource management, and how the scripts can be used for troubleshooting. It also highlights the use of `chmod +x` to grant execution permissions in Unix and provides a bibliography of the resources used.

Running head: OPERATING SYSTEMS
Operating Systems
Name of the Student
Name of the University
Author’s Note
Operating Systems
Name of the Student
Name of the University
Author’s Note
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1
OPERATING SYSTEMS
Table of Contents
Introduction................................................................................................................................2
Copies of the scripts...................................................................................................................2
Windows................................................................................................................................2
Unix........................................................................................................................................3
Discussion..................................................................................................................................5
Conclusion..................................................................................................................................6
Bibliography...............................................................................................................................7
OPERATING SYSTEMS
Table of Contents
Introduction................................................................................................................................2
Copies of the scripts...................................................................................................................2
Windows................................................................................................................................2
Unix........................................................................................................................................3
Discussion..................................................................................................................................5
Conclusion..................................................................................................................................6
Bibliography...............................................................................................................................7

2
OPERATING SYSTEMS
Introduction
The report is prepared for the creation of two Scheel script designed to run in different
environment for returning the operating system routine function. For the development of the
report some examples are evaluated and a research is done on the administrative function that
can be used for identification of the system resource usage and management of the system
components. For the development of the windows script Windows 10 operating system is
used and for the development of the bash shell script Knoppix 8.1 is used. The Unix system is
booted using VMWare and the scripts are attached with the report along with the screenshot
of the out for the demonstration of functionality of the script.
Copies of the scripts
Windows
:: The batch file is created for testing the system configuration
:: The output is stored in result.txt file.
ECHO OFF
:: Display current processes
echo The following processes are running in the current system >> result.txt
tasklist >> result.txt
:: Display current users logged in
echo The following user is currently logged in:>> result.txt
echo %username% >> result.txt
::Display device plugged in
OPERATING SYSTEMS
Introduction
The report is prepared for the creation of two Scheel script designed to run in different
environment for returning the operating system routine function. For the development of the
report some examples are evaluated and a research is done on the administrative function that
can be used for identification of the system resource usage and management of the system
components. For the development of the windows script Windows 10 operating system is
used and for the development of the bash shell script Knoppix 8.1 is used. The Unix system is
booted using VMWare and the scripts are attached with the report along with the screenshot
of the out for the demonstration of functionality of the script.
Copies of the scripts
Windows
:: The batch file is created for testing the system configuration
:: The output is stored in result.txt file.
ECHO OFF
:: Display current processes
echo The following processes are running in the current system >> result.txt
tasklist >> result.txt
:: Display current users logged in
echo The following user is currently logged in:>> result.txt
echo %username% >> result.txt
::Display device plugged in
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

3
OPERATING SYSTEMS
echo The following device is currently plugged in with the system >> result.txt
wmic logicaldisk where "drivetype =2" get VolumeName >> result.txt
echo.
:: Display overall disk usage
echo The details of the disk space is given below: >> result.txt
wmic logicaldisk get size,freespace,caption >> result.txt
echo The other details of the system: >> result.txt
systeminfo >> result.txt
:: Clear temporary files
echo The following temporary files has been deleted >> result.txt
del /q/f/s %TEMP%\* >> result.txt
Unix
#! /bin/bash
#Author :
#Declaring variables
#set -x
#1) Displaying the Current Processes:
echo "Current Processes are listed below
$(ps -aux | sort -rk 3,3 | head -n 6)" >>system.log
process_id=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
OPERATING SYSTEMS
echo The following device is currently plugged in with the system >> result.txt
wmic logicaldisk where "drivetype =2" get VolumeName >> result.txt
echo.
:: Display overall disk usage
echo The details of the disk space is given below: >> result.txt
wmic logicaldisk get size,freespace,caption >> result.txt
echo The other details of the system: >> result.txt
systeminfo >> result.txt
:: Clear temporary files
echo The following temporary files has been deleted >> result.txt
del /q/f/s %TEMP%\* >> result.txt
Unix
#! /bin/bash
#Author :
#Declaring variables
#set -x
#1) Displaying the Current Processes:
echo "Current Processes are listed below
$(ps -aux | sort -rk 3,3 | head -n 6)" >>system.log
process_id=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

4
OPERATING SYSTEMS
Process_Time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
Current_processes=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Displaying the currently logged in users:
echo " The current users Logged in th system
$(who)" >>system.log
username=`who | awk {'print$1'} | cut -f1 -d','`
date=`who | awk {'print$3'} | cut -f1 -d','`
Time=`who | awk {'print$4'} | cut -f1 -d','`
#3) Devices Plugged in
echo " Currently Devices Plugged in
$(ls -l)" >>system.log
Permission_plugged_in_device=`ls -l /dev/ | awk {'print$1'}`
#4) Overall Disk Usage
echo "Overall Disk Usage
$(du -sh)" >>system.log
Disk_Usage_for_Other_Directory=`du -sh | tail -l | awk {'print$1'}`
Plugged_in_Device=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home/ | tail -l | awk {'print$1'}`
Other_Directory=`du -sh /home/student/Downloads | tail -l | awk {'print$1'}`
#5)Network Interfaces states
OPERATING SYSTEMS
Process_Time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
Current_processes=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Displaying the currently logged in users:
echo " The current users Logged in th system
$(who)" >>system.log
username=`who | awk {'print$1'} | cut -f1 -d','`
date=`who | awk {'print$3'} | cut -f1 -d','`
Time=`who | awk {'print$4'} | cut -f1 -d','`
#3) Devices Plugged in
echo " Currently Devices Plugged in
$(ls -l)" >>system.log
Permission_plugged_in_device=`ls -l /dev/ | awk {'print$1'}`
#4) Overall Disk Usage
echo "Overall Disk Usage
$(du -sh)" >>system.log
Disk_Usage_for_Other_Directory=`du -sh | tail -l | awk {'print$1'}`
Plugged_in_Device=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home/ | tail -l | awk {'print$1'}`
Other_Directory=`du -sh /home/student/Downloads | tail -l | awk {'print$1'}`
#5)Network Interfaces states

5
OPERATING SYSTEMS
echo "network interface states
$(ip -s link)" >>system.log
network_interface_status=`ip -s link`
#6)RAM Usage
echo "RAM Consumption
$(free -hm)" >>system.log
Used=`free -hm | head -2 | tail -1 | awk {'print$3'}`
Total_Ram=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "Operating System Version
$(uname -r)" >>system.log
OS_Information=`uname -r `
#Creating directory for storing report files
if [ ! -d ${HOME}/System_Monitor ]
then
mkdir ${HOME}/System_Monitor
fi
Discussion
For the development of the shell script in windows the script is written in notepad and
it is saved in .bat extension for executing it as a batch file. The shell script is created based on
OPERATING SYSTEMS
echo "network interface states
$(ip -s link)" >>system.log
network_interface_status=`ip -s link`
#6)RAM Usage
echo "RAM Consumption
$(free -hm)" >>system.log
Used=`free -hm | head -2 | tail -1 | awk {'print$3'}`
Total_Ram=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "Operating System Version
$(uname -r)" >>system.log
OS_Information=`uname -r `
#Creating directory for storing report files
if [ ! -d ${HOME}/System_Monitor ]
then
mkdir ${HOME}/System_Monitor
fi
Discussion
For the development of the shell script in windows the script is written in notepad and
it is saved in .bat extension for executing it as a batch file. The shell script is created based on
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

6
OPERATING SYSTEMS
the terminal of the system and thus there is a change in the syntax of the codes found in
different examples to run in the Knoppix operating system. The batch script is used in the
windows environment and here the multiples process are divided into section also known as
batch and it does not need the intervention of the user. The batch script is used for performing
cross platform batch processing in the distributed network environment. The batch files are
executed in background and its output can be generated in a text file. For executing the shell
script file the file is needed to be given the root permission and for this the following
command is used.
chmod +x Sysmonitor.sh. The output of the shell script command is stored in the
system.log file that would help to identify the current status of the system. The batch script is
created for deleting the temporary files and listing the details of the system that would help to
identification of the error and troubleshooting it easily. The batch script created in the
assignment helps in identification of the process currently running on the system, disk space,
details of the logged in user, network interface and deleting the temporary files such that the
user For both the shell script and the batch script the output is stored in separate file. For the
shell script the output is stored in system.log file and for the batch file the output is stored in
result.txt file. There are different examples of scripts that are evaluated for the development
of the original script and the source of the scripts are added as reference in the report. The
original script is develop after evaluation of the system information are needed to be
displayed to the user for proper management of the system resource and that can help in
troubleshooting the errors in the system. For increasing the utility of the script the command
for deleting the temporary files are added and in the shell script the old files that are greater
than 30 months are deleted by running the script. For running the shell script ./Sysmonitor.sh
command is used and its output is stored in the log file. The batch script is written in notepad
OPERATING SYSTEMS
the terminal of the system and thus there is a change in the syntax of the codes found in
different examples to run in the Knoppix operating system. The batch script is used in the
windows environment and here the multiples process are divided into section also known as
batch and it does not need the intervention of the user. The batch script is used for performing
cross platform batch processing in the distributed network environment. The batch files are
executed in background and its output can be generated in a text file. For executing the shell
script file the file is needed to be given the root permission and for this the following
command is used.
chmod +x Sysmonitor.sh. The output of the shell script command is stored in the
system.log file that would help to identify the current status of the system. The batch script is
created for deleting the temporary files and listing the details of the system that would help to
identification of the error and troubleshooting it easily. The batch script created in the
assignment helps in identification of the process currently running on the system, disk space,
details of the logged in user, network interface and deleting the temporary files such that the
user For both the shell script and the batch script the output is stored in separate file. For the
shell script the output is stored in system.log file and for the batch file the output is stored in
result.txt file. There are different examples of scripts that are evaluated for the development
of the original script and the source of the scripts are added as reference in the report. The
original script is develop after evaluation of the system information are needed to be
displayed to the user for proper management of the system resource and that can help in
troubleshooting the errors in the system. For increasing the utility of the script the command
for deleting the temporary files are added and in the shell script the old files that are greater
than 30 months are deleted by running the script. For running the shell script ./Sysmonitor.sh
command is used and its output is stored in the log file. The batch script is written in notepad
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

7
OPERATING SYSTEMS
and saved as .bat extension and for running it the batch file is double clicked and the output
gets stored in the result file.
Conclusion
From the above report it can be concluded that for creating the script file on Unix and
windows a research is made on the different command used for getting output from the
system. Different examples of shell script created by other author are analysed and the system
administration function that can be generated with the script are also evaluated for the
development of the script. For the installation of the Unix operating system the VMware
workstation is installed in the PC on which the Knoppix operating system is installed for the
generation of the bash shell script. The scripts are tested for any error and resolved for the its
proper working and provide useful system administrative function.
Bibliography
Cannon, J. (2015). Shell Scripting: How to Automate Command Line Tasks Using Bash
Scripting and Shell Programming.
How to Use Windows Batch File Commands to Automate Repetitive Tasks.
(2016). MakeUseOf. Retrieved 8 December 2018, from
https://www.makeuseof.com/tag/use-windows-batch-file-commands-automate-
repetitive-tasks/
Johnson, S. (2018). The Complete LINUX Operating system for Absolute Beginners Guide:
Also Learn UNIX Administration, Shell Scripting, Virtual Terminal and its
application.
OPERATING SYSTEMS
and saved as .bat extension and for running it the batch file is double clicked and the output
gets stored in the result file.
Conclusion
From the above report it can be concluded that for creating the script file on Unix and
windows a research is made on the different command used for getting output from the
system. Different examples of shell script created by other author are analysed and the system
administration function that can be generated with the script are also evaluated for the
development of the script. For the installation of the Unix operating system the VMware
workstation is installed in the PC on which the Knoppix operating system is installed for the
generation of the bash shell script. The scripts are tested for any error and resolved for the its
proper working and provide useful system administrative function.
Bibliography
Cannon, J. (2015). Shell Scripting: How to Automate Command Line Tasks Using Bash
Scripting and Shell Programming.
How to Use Windows Batch File Commands to Automate Repetitive Tasks.
(2016). MakeUseOf. Retrieved 8 December 2018, from
https://www.makeuseof.com/tag/use-windows-batch-file-commands-automate-
repetitive-tasks/
Johnson, S. (2018). The Complete LINUX Operating system for Absolute Beginners Guide:
Also Learn UNIX Administration, Shell Scripting, Virtual Terminal and its
application.

8
OPERATING SYSTEMS
Windows Commands. (2018). Docs.microsoft.com. Retrieved 8 December 2018, from
https://docs.microsoft.com/en-us/windows-server/administration/windows-
commands/windows-commands
OPERATING SYSTEMS
Windows Commands. (2018). Docs.microsoft.com. Retrieved 8 December 2018, from
https://docs.microsoft.com/en-us/windows-server/administration/windows-
commands/windows-commands
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 9

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.