Solved

shell scripting help

Posted on 2002-06-16
3
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

738 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