Solved

shell scripting help

Posted on 2002-06-16
3
264 Views
Last Modified: 2010-04-20
Hi folks,

i have just set up a linux router box (LRP 2.9.8, 2.2.16 kern) that i am using as an IP accounting server.

using ipchains for accounting rules, and samba client to copy the ipchains -L output to a windows NT share.  (from there i parse the ipacc file and stuff the data into a database for prosperity ;-)

at the moment i create a set of files on the samba location as just a static name (eg /mnt/traffic/ip_acc) looks something like this:

mkdir /mnt/traffic
smbmount //ntserver/traffic$ /mnt/traffic -o username=user,password=pass

ipchains -L subnet1 -v -n > /mnt/traffic/subnet1_acc
ipchains -L subnet2 -v -n > /mnt/traffic/subnet2_acc
ipchains -L subnet_etc -v -n > /mnt/traffic/subnet_etc_acc

umount /mnt/traffic
rmdir /mnt/traffic

but i want to make this more flexible and reliable. what i would like to try to acheive woiuld be to reset the stats each time i write the output, and create a set of files with some identifier of the date and time created.

in other words, what shell script variable do i use to get my output files look like:

subnet1_acc_17_june_2002_1430

for a file written at 1:30pm today, etc.?

thanks and regards,

Mike.

0
Comment
Question by:meverest
  • 2
3 Comments
 
LVL 37

Author Comment

by:meverest
ID: 7082823
errm, i mean:

subnet1_acc_17_june_2002_1430

for a file written at 2:30pm today, etc.?

:-}

0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 7083342
ipchains -L subnet1 -Z -v -n > /mnt/traffic/subnet1_acc_`date +"%d_%b_%Y_%H%M"`
0
 
LVL 37

Author Comment

by:meverest
ID: 7084588
eeexcellent! thanks :)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question