Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for df -k

Status
Not open for further replies.

ranjank

IS-IT--Management
May 9, 2003
176
IN
Hi,

I want to do first the space checking by doing df -k.I want to do this before copying data in to other server.For e.g...
1) login to other server
2) Checking space (df -k )If space is 80% and above then don't copy the data adn quit.Else copy the data.

Can anyone give some leads in this.

Regards,
RK
 
for logging to the distant server, use ssh with authorized_keys file and the you may execute something like that:

for i in `df -k | awk '{print $5}' | sed 's/\%//g'`
do
if [ $i -ge 80 ]
then
echo "dont copy"
else
echo "copy"
fi
done

 
Thanks.I tried this but it logs in to the other server and did execute the check condition.I'm doing this...

ssh -l abd 172.1.1.10
for i in `df -k | awk '{print $5}' | sed 's/\%//g'`
do
if [ $i -ge 80 ]
then
echo "dont copy"
else
echo "copy"
fi
done
It ssh in to 172.1.10 and dosen't execute the for loop.Any idea why it is not doing.
Any help on thsi will be greatly appreciated.

Regards,
RK.
 
Hi

You tried exactly as you post it ? No way to work. The [tt]for[/tt] will be executed locally after the [tt]ssh[/tt] command terminate. Try this :
Code:
ssh -l abd 172.1.1.10 [red]<<EOF[/red]
for i in `df -k | awk '{print $5}' | sed 's/\%//g'`
do
[gray]# whatever...[/gray]
done
[red]EOF[/red]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top