Unix space checking script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Unix space checking script
# 1  
Old 02-03-2011
Bug Unix space checking script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Im still pretty new to this and could really use some help with this task

"Write a script to check in the directory specified by
the first argument, if there is enough free space specified by the second
argument. Provide a comprehensive examination of the arguments."


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
New Bulgarian University, Sofia, Bulgaria, for professor Simionov course number CSCB731

Thanks to everyone and this forum

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 02-03-2011
what are you expecting? where are your problems?

usefull commands you might want to use: "df" and "du".

look at the mapages of the commands and see if this gets you any further.
# 3  
Old 02-03-2011
Please mention what Operating System you are running and what Shell you use:
Code:
uname -a
echo $SHELL

# 4  
Old 02-03-2011
What have you tried so far ?

The knowledge can only be get by practice
# 5  
Old 02-03-2011
Hint. This command gives the free disc space available in a filesystem containing a particular drectory. It works on most modern unix systems.
Code:
df -Pk /directory

# 6  
Old 02-04-2011
Thanks alot for your hints and help.
This is the result I came up with, but my pc died yesterday and I am now only able to access internet club pc's and cannot test the code yet, can someone please give a look and tell me if it's wrong. Thanks alot guys
Code:
if [ -d directory ]
then
  du -hs directoryname
else 
  echo Directory not found
fi


Last edited by Scott; 02-04-2011 at 07:22 AM.. Reason: Added code tags
# 7  
Old 02-04-2011
You are using du (disk usage). This tells you nothing about the availability of space.

As was previously mentioned the df command will show free space.

If you don't have access to manpages, you can read them here.

man pages link
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX script to find alerts for swap space

Can someone get me script to find swap space for linux servers (1 Reply)
Discussion started by: Moon1234
1 Replies

2. Shell Programming and Scripting

Help needed to create a UNIX Space monitoring script

Hi All, Its urgent.. pls help me out.. I want to create a KSH which should generate a report with the list of users and the files larger than 5 GB created by them in a direcorty and send autogenerated e-mail to them. my input would be users list,directory path and the file size (say 5 GB) ... (11 Replies)
Discussion started by: anman0523
11 Replies

3. Solaris

UNIX Checking Tape Space

Hello. My name is Alex and I am new to the UNIX environment. One of the things that I do on a daily basis is I perform backups to tape on a Sun Ultra 25. I use DAT72 tape. The tape that is currently in the tape drive has about five database backups within it already. I was just hoping... (19 Replies)
Discussion started by: daddy.torres
19 Replies

4. UNIX for Advanced & Expert Users

Checking missing data's sequence (shell script | UNIX command)

Dear All members, i have some trouble here, i want to ask your help. The case is: I have some data, it's like: -ABCD1234 -ABCD1235 -ABCD1237 -BCDE1111 -BCDE1112 -BCDE1114 there is some missing data's sequence (the format is: ABCD = name 1234 = sequence). I want to print the... (2 Replies)
Discussion started by: septian.tri
2 Replies

5. UNIX for Advanced & Expert Users

Checking the space for /archlog mount point script

I have the below shell script which is checking /archlog mount point space on cappire(solaris 10) server. When the space usage is above 80% it should e-mail. When i tested this script it is working as expected. #!/usr/bin/ksh export MAIL_LIST="tlr.voora@zamn.com" export ARCH_STATUS=`df -k... (1 Reply)
Discussion started by: dreams5617
1 Replies

6. Shell Programming and Scripting

Checking the space for /archlog mount point script

I have the below shell script which is checking /archlog mount point space on cappire(solaris 10) server. When the space usage is above 80% it should e-mail. When i tested this script it is working as expected. -------------------------------------------------------------------------... (0 Replies)
Discussion started by: dreams5617
0 Replies

7. Shell Programming and Scripting

Unix script for Checking sequence

Hello, I need Unix script for Checking sequence and get output in a file for missing sequences information. We are moving archive log to a server for DR .if any files miss from sequence DR will fails. so we need script to monitor sequence of files which are FTP from the Production servers .... (2 Replies)
Discussion started by: Rata_raj
2 Replies

8. UNIX for Dummies Questions & Answers

Problem in checking space of mount.Please help me

Hi everyone, I am writing a script. As a part of this script, I wanted to check the space of few mounts, If the space usage percentage of the mount crosses over a certain limit then i wanted to display a warning message. The following is the command df -k | awk ' { if (($6 == "/export/temp")... (4 Replies)
Discussion started by: Sheethal
4 Replies

9. Shell Programming and Scripting

Checking availability of Web pages through Unix script

Hi Guru's, I need to check the availability of a web page for every one hour through a script. Following is the requirement. 1. Go to http://vsn.srivsn.com 2. If any error encountered in openeing the home page, it should trigger an email with the appropriate error message. 3. If page opens... (6 Replies)
Discussion started by: srivsn
6 Replies

10. UNIX for Dummies Questions & Answers

checking for a space in a file name

hi members... another new probs... i need to check all the zip files in the server and check for a space or "`" in the file name and if found need to remove them and form a zip file. i tried using grep command to check for a space but with out success also when i tried checking for "`" as... (6 Replies)
Discussion started by: madhu_aqua14
6 Replies
Login or Register to Ask a Question