Sponsored Content
Full Discussion: Bash Programming
Top Forums Shell Programming and Scripting Bash Programming Post 302314089 by bumdeal2 on Thursday 7th of May 2009 10:52:47 AM
Old 05-07-2009
Bug Bash Programming

Write a Shell script to analyse the disk usage of students in a particular class.
The program should allow the user running the script to input the particular class name (group name) as an argument to the script.
The script should create a file called “logfile” in the home directory of the user running the script. The first line of logfile should contain the heading:
“List of members of class “classname” on “today's time and date
For each member of the class, the script should record in the logfile on separate lines:
The username
The total number of files in the student's home directory
The total disk space used by the student
The last line of the logfile should contain the total number of students found in the class.

The information which you need on usernames, groupnames and group id's is contained in two files.
The first file is /etc/group. This file has a line for each group (class) containing the following information:
groupnameSmilieassword:groupid:secondary members. The file uses colon : as a field separator.
The second file is /etc/passwd. This file has a line for each user containing the following information:
username:x:userid:groupid:comments:home directory:default shell. The file also uses colon : as a field separator.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Programming in ksh and not in bash

Hi all.... I was wondering if there is a lot of differences between /bash and ksh programming. Im learning about bash programming, but all what I had read in this forum, points me to learn more about ksh over bash. Is that right and why? Unfortunately, I can’t write ksh progs on my work,... (2 Replies)
Discussion started by: TARFU
2 Replies

2. Shell Programming and Scripting

help bash programming

how to i grep a keyword which ignore upper case or lower case. for an example : user enter CoUcH and the grep also can grep couch which in text.txt although upper or loever case is different .. how to do that ? any idea? (1 Reply)
Discussion started by: CheeSen
1 Replies

3. Shell Programming and Scripting

bash programming

how do you allow a user to input a particular group name as an argument?? thnx for your time. (2 Replies)
Discussion started by: bumdeal2
2 Replies

4. Shell Programming and Scripting

Bash time and programming

I have inherited a C++ program which does not manage it's memory at all. It has a whole bunch of 'new' variables without many deletes. I believe it was the programmers intent to let the OS clean up. Correct me if I am wrong, but I believe the unix/linux systems clean up after the program... (1 Reply)
Discussion started by: JDKunk
1 Replies

5. Shell Programming and Scripting

Example in Pro Bash Programming book problem

I am going through the examples in the book "Pro Bash Programing" which is quite a good book on bash programing. Just a word of warning about the example script called sa that simply shows command line arguments. In CentOS 5.5 there is a program called sa already on the system. Boy did that throw... (0 Replies)
Discussion started by: simusphere
0 Replies

6. Shell Programming and Scripting

Bash programming help

Hello all; I have little knowledge of bash programming, and I was wondering if you could help me out. I would like to create a bash script, as detailed below. process.sh is the bash script itself list.dl is a text file. In this text file, the first line is the directory from... (1 Reply)
Discussion started by: tehalexf
1 Replies

7. Homework & Coursework Questions

Bash Shell Programming assignment.

Please take a look I am stuck on step 4 1. The problem statement, all variables and given/known data: #!/bin/bash ### ULI101 - ASSIGNMENT #2 (PART A) - DUE DATE Wed, Aug 3, 2011, before 12 midnight. ###==================================================================================== ###... (13 Replies)
Discussion started by: almirzaee
13 Replies

8. Shell Programming and Scripting

ctrl-c in bash script - Programming

Hi All, I need to place a ctrl-c interrupt in a bash script, there is no other way, it has to be done :) can someone please advise how would I go about this? i want to use ctrl c in below code, after the code excution of just 1 min or 1sec java Cspsamp 111.19.5.172 7025 rd1... (6 Replies)
Discussion started by: aish11
6 Replies

9. Shell Programming and Scripting

Chunks of bash shell programming

I am going to provide a chunks of codes that I do not understand. Please help with them in a layman's terms. 1) ${DEBUG:-0} -------------------------------------------------------------------------- 2) print "${1}" ... (7 Replies)
Discussion started by: lg123
7 Replies

10. Linux

Bash Programming. Could anyone help me?

Hi! I'm new in bash programming and I need to make an script that reads a txt file line by line (every line is like "Name;FirstLastName;SecondLastName;Sex") and has to give every student 3 random marks, its average and add a counter if they are male/female and if they passed. I've been trying with... (4 Replies)
Discussion started by: HeartHacker
4 Replies
class_admin(8)						      System Manager's Manual						    class_admin(8)

NAME
class_admin - Administer class scheduling and the database. SYNOPSIS
/usr/sbin/class_admin [subcommand] DESCRIPTION
The class_admin command is used to configure and control the class scheduler and to maintain its database /etc/class. The class_admin command can be run interactively or non-interactively. Non-interactive mode is useful when you would like to execute a single class_admin subcommand without user interaction. This allows class_admin to be run from within a script, which makes it easy to enable class scheduling at system startup through use of an init(8) script. To run class_admin non-interactively, specify a single class_admin subcommand as an argument when invoking class_admin. Interactive mode is useful when you would like to execute several class_admin subcommands. To run class_admin interactively, invoke class_admin without specifying a subcommand argument. Should the class scheduler database not exist, class_admin will automatically create one when it starts up. If the command is invoked non- interactively, a default database is created (using the following interactive defaults). The interactive process will require you to answer three questions: Shall processes that have not been explicitly assigned to a defined class be assigned to a "default" class? Enter (y/n) [n]: To be class scheduled, a process must be assigned to a class. If you answer <y> to this prompt, a special class called the "default" class will be created, and any process that has not been explicitly assigned to one of the defined classes will be assigned to this class. If you answer <n> to this prompt, then only those processes which have been explicitly assigned to a defined class will be class scheduled. Enforce class scheduling when the CPU is otherwise idle? (y/n) [n]: The administrator has the option of allowing classes to exceed their CPU percentage when the system is otherwise idle if yes is answered. Otherwise, classes are held to their allotted percentage even if the CPU has no other work. How often do you want the system to reset class usage? Enter number of seconds (2): Use a small number (several seconds) if there are interactive jobs subject to class scheduling to give them a quick response time. If only batch jobs are class scheduled, response time is not an issue and larger values may be used. If class scheduling is enabled, changes made take effect immediately. Subcommands Add a group or user to an existing class. If the group or user exists in another class, you will be asked if you want to move it or not. More than one group or user may be specified. Syntax: add <class name> <type> <id ... ...> <type> = 'gid' | 'uid' | 'session' | 'pgrp' | 'pid' Change the CPU percentage allotted to a class. The system will not allow the total of all classes to exceed 100%. Syntax: change <class name> <cpu %> Create a new class. The name must be unique. The newly created class will be empty. Use the add command to populate the class. Syntax: create <class name> <cpu %> Set up the basic class scheduling parameters. You will be prompted for each parameter. Syntax: configure Remove a group or user from an existing class. More than one group or user may be specified. Syntax: delete <class name> <type> <id ... ...> <type> = 'gid' | 'uid' | 'session' | 'pgrp' | 'pid' Destroy an existing class. If the class is not empty, you will be asked if it's OK to destroy it anyway. Syntax: destroy <class name> Turn off class scheduling for the system. Note that the kernel will terminate the class scheduler dae- mon. Syntax: disable Turn on class scheduling for the system. A daemon will be started that periodically examines class CPU usage and adjusts access of a class to the CPU depending on its percentage. Syntax: enable Return to the command shell. If any permanent changes were made to the database, You will be asked to save or dis- card them. (Same as `quit'). Syntax: exit On-line help. If a subcommand is specified, detailed information pertaining to that subcommand is displayed. Other- wise, a list of all subcommands and their arguments is displayed. Syntax: help [<subcommand>] Return to the command shell. If any permanent changes were made to the database, You will be asked to save or discard them. (Same as `exit'). Syntax: quit Change the name of an existing class. Syntax: rename <old name> <new name> Write permanent database changes to the disk and continue. Syntax: save List the configured classes, the CPU percentage allocated to each class, and members assigned to it. If no class name is specified, all classes will be shown. Syntax: show [<class name>] List the current CPU utilization of a class. If no class name is specified, all classes will be shown. Syntax: stats [<class name>] FILES
SEE ALSO
Commands: runclass(1), class_scheduling(4) class_admin(8)
All times are GMT -4. The time now is 05:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy