CNT=8; for i in `cat listado`; do sed "s/Z/$i/g;s/X/$CNT/g" template && let CNT++; done
listado:
172.16.170.0
172.16.145.0
172.16.130.0
172.16.140.0
172.16.160.0
172.16.135.0
172.16.155.0
172.16.165.0
template:
ADDRESSX=Z
GATEWAYX=172.16.32.7
NETMASKX=255.255.255.0
#!/bin/bash
PLAYLISTS=( rock_tracks.m3u jazz_songs.m3u shazam_01.m3u best_albums.m3u )
ROOTDIR=/home/user/Music/Playlists
DSTDIR=/home/user/Board
CMD="/usr/bin/rsync --progress -u"
TMP=`pwd`/.temp
mkdir $TMP
for i in "${PLAYLISTS[@]}"
do
grep -v "^#" $ROOTDIR/$i | while read tracks; do du -k "${tracks}" >> $TMP/${i}.sum; done
done
cd $TMP
for i in *.sum
do
FILE=`echo ${i} | sed s/.sum//g`
SUM=`cat ${i} | awk '{total=total+$1} END {print total}' | awk '{ human = $1 / 1024} END {print human" M"}'`
echo -e "$FILE == >> $SUM"
done
cd ..
echo -e "Do you want to synchronize the playlists? (y/n)"
read answer
if [ $answer = y ]
then
for i in ${PLAYLISTS[@]}
do
DIRNAME=`echo ${i} | sed s/.m3u//g`
mkdir -p $DSTDIR/"${DIRNAME}"
grep -v "^#" $ROOTDIR/$i | while read tracks; do $CMD "${tracks}" $DSTDIR/"${DIRNAME}"; done
ls -tr $DSTDIR/"${DIRNAME}" > $TMP/${i}
mv $TMP/${i} $DSTDIR/"${DIRNAME}"
done
fi
if [ $answer = n ]
then
echo -e "OK"
fi
rm -r $TMP
#!/usr/bin/perl
use MIME::Lite;
my $attached_file = $ARGV[0];
my $report_directory = "/mnt/reports";
my $msg = MIME::Lite->new(
From => 'xxxx@xxxx.com',
To => 'xxx@xxx.com',
Cc => 'xxxx@xxxx.com, xxxxx@xxxx.com',
Bcc => 'xxx@xxx.com, xxx@xxx.com',
Subject => "$attached_file",
Type => 'multipart/mixed',
);
$msg->attach(
Type => 'TEXT',
Data => "Mensaje : $attached_file \nNota: Este correo ha sido generado automáticamente por favor no responda a este mensaje.",
);
$msg->attach(
Type => 'text/plain',
Path => "$report_directory/$attached_file",
Filename => "$attached_file",
Disposition => 'attachment'
);
$msg->send or die "Mensaje no enviado";
system("rm -rf $report_directory/$attached_file");
------------ bash execution ------------------------
#!/bin/bash
report_directory="/mnt/reports"
exec_directory="/root/bin"
cd $report_directory
for i in *.csv; do $exec_directory/send_email_file_report.pl $i; done