Sponsored Content
Full Discussion: Disk Capacity Shell Script
Homework and Emergencies Homework & Coursework Questions Disk Capacity Shell Script Post 302613137 by agama on Monday 26th of March 2012 07:59:19 PM
Old 03-26-2012
A few things I noticed:

1) you need to read into a variable (I assume output). The syntax would be something like command | while read output. Possibly this is a cut/past error when sharing your code.

2) You are missing ending double quotes in your echo statements that are being used to fill the body of the mail.

3) Your mail commands need to be on the same line as your echo (this might have been a copy/past problem and not something wrong in your code)

4) You are assigning the percentage and partition backwards. The output from the df command is partition ($1) then percentage ($2), but you are assigning percentage from $1 and partition from $2.

5) The reason you are getting 'missing ]' errors is because you cannot use && as a part of a single bracketed expression. The easy fix is to make this two expressions:

Code:
if [ $a = "foo" ] && [ $b = "bar" ]
then

I'm not sure that old Bourne shell (sh) supports this, so you might consider using ksh or bash instead.

Hope these suggestions get you going again.

---------- Post updated at 19:59 ---------- Previous update was at 19:52 ----------

Also thought I'd toss in a quick trick. You could make things a bit more efficient by reading directly into your percentage and partition variables. Consider this small script:

Code:
ls -al | awk '{printf( "%d %s\n", $5, $NF}' | while read size name
do
    echo "name=$name size=$size bytes"
done

Using printf with %d will also remove your trailing percent sign without the need for invoking a cut process.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix disk capacity at 100%

Is there any danger to keeping one of my disks at 100% capacity? (it's a disk just used for read-only files, not system files or anything like that). It's HP-UX if that matters. Thanks! (1 Reply)
Discussion started by: FredSmith
1 Replies

2. Solaris

Migrate VxVM boot disks to higher capacity disk

Hi, Im getting a downtime of 4 hrs to do porting of bootdisks. Currently, the system is running on Sf4800. 2 internal disk 36G connected to a SE3510 storage. We're getting 72G disks and we want to restore the OS from the current 36G to the 72G disk. System is under veritas volume manager ctrl.... (4 Replies)
Discussion started by: incredible
4 Replies

3. Shell Programming and Scripting

shell script to create disk load

friends , need a shell script to create a disk load. can any one pls guide me with how this can be implemented. Pls provide the concept. from there i will try to design my script. (3 Replies)
Discussion started by: achak01
3 Replies

4. Shell Programming and Scripting

File system capacity meter in shell

HI i need help to show the file system capacity in meter or like the progress bar . OS = Solaris 10 (8 Replies)
Discussion started by: bejo4ever
8 Replies

5. AIX

how to find out disk capacity

Hi, I would like to know how to find out disk capacity if it is assigned from the storage as a lun. as per below command , I am unable to find out disk capacity. $ bash bash-3.00$ lspv hdisk1 0001579a7fa3c086 None $ lscfg -vl hdisk1 hdisk1 ... (8 Replies)
Discussion started by: manoj.solaris
8 Replies

6. Shell Programming and Scripting

Shell script to find filesystem capacity on 50 servers

Hi all, I am new to Unix and I want to write a shell script in a jumpbox for finding the filesystem capacity on 50 unix servers ( by ssh ) and then email the result in HTML format with server name and capacity % to a specific outlook distribution list. any suggestion would be of great help. (17 Replies)
Discussion started by: amitbisht9
17 Replies

7. Shell Programming and Scripting

Help with Disk Space script in bash shell

Hi Guys, I'm a newb at shell scripting and successfully attempted a small disk space script (victory!!) but i'm wondering whether it actually takes into consideration KB,MB,GB. Please take a look at the script and advise. ##script to check if file sys has reached threshold. ... (3 Replies)
Discussion started by: Irishboy24
3 Replies

8. Shell Programming and Scripting

disk quotas shell script

Hello.. I wrote the following shell script to run disk quotas for assigning limits to users. I need to know the partition which the user has created and mount it. So i copied the partitions (which will be displayed after running fdisk -l) and separted the last line from it and cut the required... (0 Replies)
Discussion started by: kalyanilinux
0 Replies

9. UNIX for Dummies Questions & Answers

Tru 64 Disk Capacity Check

i have a query on checking Tru64 disk drives physical capacity. i used hwmgr view devices and saw this disk. 160: /dev/disk/dsk7c COMPAQ BF03688284 bus-3-targ-0-lun-0 checking the model on the internet shows it is a 36.4GB drive. i checked the disk details and saw the... (2 Replies)
Discussion started by: iamnotaguru
2 Replies

10. Shell Programming and Scripting

Help me with C-shell Script: Disk checking

Hi, i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : 100.21.25.12 cal 4 : 100.21.25.14 and so on... Right now, i have this. #! /bin/csh -f ... (0 Replies)
Discussion started by: lattey
0 Replies
icapd(1M)																 icapd(1M)

NAME
icapd - Instant Capacity (iCAP) daemon. SYNOPSIS
icapd DESCRIPTION
The (formerly ) daemon is installed and started as part of the Instant Capacity software on all potential iCAP systems, and respawns itself if killed. If this daemon is not running, other Instant Capacity commands fail. The operations this daemon performs are vital in keeping the complexwide view of the Instant Capacity state current. The following entry is added to /etc/inittab in order to have start and respawn itself: icap:23456:respawn:/usr/lbin/icapd # Instant Capacity daemon This daemon is not started on hardware that is not supported under the Instant Capacity program. If is installed and running on a system with Instant Capacity components present (cores, cells, or memory), it sends daily asset report email to HP (if so configured), tracks tem- porary capacity, sends exception notifications, and maintains a healthy Instant Capacity state. For more information about the functions that performs for Instant Capacity systems, see the located at /usr/share/doc/icapUserGuide.pdf. The daemon reports errors via (see syslog(3C)). Exception notification email is sent to root and to the system contact email address (con- figured via the command (see icapmodify(1M)). The daemon performs periodic operations based on the time of day. The daemon is spawned by and gets its time zone specification from the /etc/default/tz file. By default, the time zone specified in /etc/default/tz is EST5EDT. You can specify which time zone the daemon uses to interpret its current time by modifying the /etc/default/tz file. For details about the time zone format, see environ(5). A restart of the daemon is required before the new time zone value takes effect (that is, kill the process). AUTHOR
was developed by HP. SEE ALSO
icapmodify(1M), icapstatus(1M), icapnotify(1M), icapmanage(1M), icap(5). icapd(1M)
All times are GMT -4. The time now is 08:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy