LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Bash script for listing FTP usage as the file name of a file created in each share (http://www.linuxquestions.org/questions/programming-9/bash-script-for-listing-ftp-usage-as-the-file-name-of-a-file-created-in-each-share-688602/)

jojothedogboy 12-05-2008 03:58 PM

Bash script for listing FTP usage as the file name of a file created in each share
 
I admin a FTP server and need help setting something up to allow the FTP users to see if their individual share is full.

Set-up:
A Fedora Core 6 system running vsftp using LVM to segregate FTP shares (matching the directory names to the logical volume names).
Also, there are multiple accounts per share (ex: share "sales" has accounts "john" and "tom" that are separate chrooted directories inside of the "sales" Logical Volume.

Idea:
I have a cron script that does this:
Code:

df -H /dev/mapper/SCSI_RAID5-LogVolName | grep -v /dev/mapper/SCSI_RAID5-LogVolName | cut -c 24-47 > /data/LogVolName/ShareName/_FTP_Usage.txt
Results look like this:
Code:

Size  Used  Avail Use%
 37G    33G  2.9G  92%
20081205-1201

I couldn't figure out how to put the usage info into the file name (just an empty file titled "Usage-2.9G_Avail_out_of_37G.txt" or something) and each login/account needs to be a separate line of code.

What I'm looking for is help writing a script that will dynamically read which LogVols are currently in use then create files titled with account usage info written into the root of the appropriate account directories.

Any ideas? Even if you can just get me part of the way... any little bit helps. And if I'm totally missing the mark on this then please tell me! Anyway to let users see the amount of available space in their share will do the job.

-Thanks,

jojothedogboy 12-05-2008 04:35 PM

Maybe something like:
Code:

#!/bin/bash
for i in $( cat fstab.test | grep /dev/SCSI-RAID5 | cut -f 1 ); do
df -H $i | cut -c 24-47 | grep -v Size | tee ~/df.test.log
done

Would something like that work?


All times are GMT -5. The time now is 11:01 PM.