Solved

shell scripting help

Posted on 2002-06-16
3
258 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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.:
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now