Sponsored Content
Top Forums Shell Programming and Scripting Require Help for Shell Script Post 302163152 by jagnikam on Thursday 31st of January 2008 05:47:52 AM
Old 01-31-2008
Data require help for Shell Script

Quote:
Originally Posted by panknil
Dear jagnikam,

ur code fine, but take care about the syntax of scripting
i have just corrected ur basic faults...

try it out

#!/bin/bash
Warning=90
df -h | sort -rn | awk '{print $5 " " $1 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $Warning ]
then
echo "Running out of space \"$partition ($usep%)\""
else
echo "This partition have enough space \"$partition ($usep%)\""
fi
done

and my one more suggestion is redirect the output if df -k in a file and the remove the first line of the file and then proceed...
ur current code is proceeding with the first line also which u dont need.

Regards,
Pankaj
thanks for reply
I got this output after executing script provided by U. actually i am using NFS & some drive mounted on my HDD. this creating problem for me .

This partition have enough space "192.168.0.2:/usr (38%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/nodes/192.168.0.106/var: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/nodes/192.168.0.106/var%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/nodes/192.168.0.106/etc: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/nodes/192.168.0.106/etc%)"
./test1.sh: line 7: [: 192.168.0.2:/tftpboot/node_root: integer expression expected
This partition have enough space " (192.168.0.2:/tftpboot/node_root%)"
./test1.sh: line 7: [: 192.168.0.15:/var/spool/mail: integer expression expected
This partition have enough space " (192.168.0.15:/var/spool/mail%)"
./test1.sh: line 7: [: 192.168.0.15:/tftpboot/node_root/var/lib/dpkg: integer expression expected
This partition have enough space " (192.168.0.15:/tftpboot/node_root/var/lib/dpkg%)"
./test1.sh: line 7: [: 192.168.0.15:/neuralit/work: integer expression expected
This partition have enough space " (192.168.0.15:/neuralit/work%)"
./test1.sh: line 7: [: /home: integer expression expected
This partition have enough space "110G (/home%)"
./test1.sh: line 7: [: /var/lib/dpkg: integer expression expected
This partition have enough space "65G (/var/lib/dpkg%)"
./test1.sh: line 7: [: /var: integer expression expected
This partition have enough space "65G (/var%)"
./test1.sh: line 7: [: /etc: integer expression expected
This partition have enough space "65G (/etc%)"
./test1.sh: line 7: [: /: integer expression expected
This partition have enough space "65G (/%)"
./test1.sh: line 7: [: /var/spool/mail: integer expression expected
This partition have enough space "6.0G (/var/spool/mail%)"
This partition have enough space "varrun (1%)"
This partition have enough space "varlock (1%)"
This partition have enough space "tmpfs (1%)"
This partition have enough space "tmpfs (0%)"
This partition have enough space "tmpfs (0%)"
This partition have enough space "none (1%)"
./test1.sh: line 7: [: Use: integer expression expected
This partition have enough space "Filesystem (Use%)"
This partition have enough space "devshm (0%)"



Please Help me

Tanks & Regards

Jagannath Nikam
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding use and require keywords

Hi, what is the difference between use and require keywords in Perl. What is the significance of these lines (what it mean, what is the use of this) #!/usr/bin/perl -w // In Perl script.... #!/bin/ksh //In shell script..... Thanks Sweta (2 Replies)
Discussion started by: sweta
2 Replies

2. UNIX and Linux Applications

Getmail help require

Hi all, I am retrieving mail from live mail server to local mail server. I want to know that, how can i exclude some peoples from getmail domain retrival. verbose = 1 read_all = true delete_after = 30 message_log = ~/.getmail/log type = MultidropIMAPRetriever server = mail.abc.com... (0 Replies)
Discussion started by: jagnikam
0 Replies

3. Solaris

Require some way or shell in which commands doesnot gets logged in history file

Guys, can u tell me some way in which the commands i execute on solaris system doesnot gets logged. It should not appear in history file.. Is there any shell which provide such solution or can I turn off the logging, if yes then how... Help will be appreciated Thanks (2 Replies)
Discussion started by: harpreetrekhi
2 Replies

4. Shell Programming and Scripting

Require script to create two files

Hi folks, I have a input.file with the following contents:- flor geor enta vpal domi pegl cars mted four rose annc gabi ward dalv elph beac (8 Replies)
Discussion started by: mithalr
8 Replies

5. Shell Programming and Scripting

sed help require

sed 's/abcd/$variable/g' abcd_calls > $variable_calls This is the statement i am trying which has 2 errors in it. 1st- sed 's/abcd/$variable/g' is changing abcd to $variable in the file abcd_calls ,I want it to convert abcd into the string value given by user through read command, taking... (1 Reply)
Discussion started by: learnbash
1 Replies

6. Programming

REQUIRE HELP IN WRITING A PERL SCRIPT

Hi everyone I am a beginner in perl and I am trying to write a perl script. Basically I want to separate gene entries from phenotype entries in a text file which contains huge number of records and copy them in a separate file. The gene entries will have * symbol after the line FIELD TI. A... (7 Replies)
Discussion started by: kaav06
7 Replies

7. Shell Programming and Scripting

Require single command to start script in multiple servers

I have 9 servers, on each server a script with common name is available. I send a token file to all server from 1 particular server. so when a daemon job checks that token file is available then it triggers the script.. I want to know is there any command or script which I will run/execute on... (16 Replies)
Discussion started by: mirwasim
16 Replies

8. Shell Programming and Scripting

How to automate a script that would require authentication?

Hey everyone... I'm just stretching my wings a bit and seeing how things work. If I wanted to write a script that had me ssh to my remote computer, how can this be done? If the script runs without me, how can I enter the required password? the same is true for any time of authentication method like... (2 Replies)
Discussion started by: Lost in Cyberia
2 Replies

9. UNIX for Beginners Questions & Answers

Require help in creating a Sudo/Shell script

Hello Friends, I have a scenario to create a script, I know many of you feel this as simple script. I am not much familiar with unix scripting, please help me out. Situation:- 1. I have a list of config files like 40+ would be getting deployed in the /app/abcd/src/Config/ (This will... (2 Replies)
Discussion started by: ganjvin
2 Replies

10. UNIX for Beginners Questions & Answers

Script require to do telnet & run few commands

I am new in scripting, I need script(BASH) which do telenet to one of the elements & run few commands , after running it successfully it will check status of files & exit. Help is greatly appreciated 🙏 (2 Replies)
Discussion started by: Vinesh_123
2 Replies
All times are GMT -4. The time now is 11:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy