Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

shell scripting help

Posted on 2002-06-16
3
Medium Priority
?
272 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

636 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