• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

shell scripting help

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
meverest
Asked:
meverest
  • 2
1 Solution
 
meverestAuthor Commented:
errm, i mean:

subnet1_acc_17_june_2002_1430

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

:-}

0
 
ahoffmannCommented:
ipchains -L subnet1 -Z -v -n > /mnt/traffic/subnet1_acc_`date +"%d_%b_%Y_%H%M"`
0
 
meverestAuthor Commented:
eeexcellent! thanks :)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now