Need perl script
Hi,
--- On Fri, Mar 5, 2010 at 6:19 AM, Vinod H Parmar
| I need to check day and time to send that file on that particular day and
| time only.
\--
So, why maintain the list in a single file? How do you populate that
file, and how often is it done?
SK
--
Shakthi Kannan
http://www.shakthimaan.com
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
I want to manage single file as configuration file, if any body wants his file at some particular time who don't know scripting he just need to edit this file and one line with his file path, email Id and day-time on which he needs his file to be send to him.
With Regards,
Vinod Parmar
(Cell - 9825414974)
Hi,
--- On Fri, Mar 5, 2010 at 6:19 AM, Vinod H Parmar
| I need to check day and time to send that file on that particular day and
| time only.
\--
So, why maintain the list in a single file? How do you populate that
file, and how often is it done?
SK
--
Shakthi Kannan
http://www.shakthimaan.com
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
Hi,
--- On Fri, Mar 5, 2010 at 1:09 PM, Vinod H Parmar
| I want to manage single file as configuration file,
\--
Sorry, but, your terminology is very confusing. You are using the file
as a log file, that changes w.r.t. time. A configuration file is for
an application/service that has settings information, and shouldn't be
changed, unless required. All resource stakeholders who are using the
service/application must be notified before the change.
---
| if any body wants his
| file at some particular time who don't know scripting
\--
People who don't know scripting shouldn't touch configuration files :)
---
| he just need to edit
| this file and one line with his file path, email Id and day-time on which he
| needs his file to be send to him.
\--
Edit the file, manually! How do you protect from not removing some one
else's entries?
Please don't call it 'day-time'. You only have a weekday and a time.
How does anyone know which month, year it is from?
Date-time is YYYY-MM-DD HH:MM:SS. For example, 2010-03-05 13:32:00,
means March 5, 2010 at 1:32 PM from the systems' timezone. You also
have to think about timezone!
I suggest you analyze all the above, and refine your requirements. It
would also help if you give us the big picture as to what you are
trying to do, rather than making lot of assumptions like the above.
Regards,
SK
--
Shakthi Kannan
http://www.shakthimaan.com
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
With Regards,
Vinod Parmar
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
I have written little PERL code for you in hurry.
You can use this ->
i) Copy and paste PERL code in a file. Let say, in hehe.pl
ii) Make it executable and execute like this - ./hehe.pl filename.txt
Code is begin from here ->
#
# By HeHe
#
use strict;
use Mail::Send;
open FILE, "<$ARGV[0]";
my ($FilePath, $DayTime, $Email);
while (my $Line = <FILE>) {
if ($Line =~ /(.+)\s(\w{3}\-\d{1,2})\s(.+)/m) {
$FilePath = $1;
$DayTime = $2;
$Email = $3;
}
if ($DayTime eq 'FRI-18' or $DayTime eq 'SAT-10') {
&SendMail($FilePath, $Email);
}
}
close FILE;
sub SendMail($;$) {
my $Command = 'echo "Hey, Message from HeHe" | mutt -s "HeHe Mssg" -a '.$_[0].' '.$_[1];
if (system($Command)) {
return 1;
} else {
return 0;
}
}
< - Code is over here
But i have used here system mutt binary for sending mail you can replace mail sending procedure via Mail::Send module.
Please let me know if you have any doubt in this code.
Enjoy,,,,,, :-)
Thanks
Pankaj
Hi,I have one file myfile.txt which has two lines written.vim myfile.txt/home/user1/test.doc FRI-18 xyz@mydomain.com/home/user2/test2.xls SAT-10 xyz1@mydomain.comI want perl script which read this myfile.txt file and check day and time (e.g. FRI for Friday and 18 for 18:00),if current day and time is FRI-18 then it attach file /home/user1/test.doc send email to xyz@mydomain.comif current day and time is SAT-10 then it attach file /home/user2/test2.xls and send email to xyz1@mydomain.com
With Regards,
Vinod Parmar--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
Hi,
Some thoughts below:
--- On Sat, Mar 6, 2010 at 7:44 PM, Pankaj Pratap Singh
| open FILE, "<$ARGV[0]";
\--
Always check for return status! or die "Cannot open file: $!\n"
---
| if ($DayTime eq 'FRI-18' or $DayTime eq 'SAT-10') {
\--
That is not what the OP asked for! It has to be for any date and time.
---
| &SendMail($FilePath, $Email);
\--
That is not what the OP asked for!
E-mail has to be sent only on that specific date, and time. With the
above script, how often do you intend to run the script? If you have
already sent an e-mail, and if you re-run the script, it will send
duplicate e-mails.
SK
--
Shakthi Kannan
http://www.shakthimaan.com
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG
With Regards,
Vinod Parmar
(Cell - 9825414974)
--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG-unsubscribe@googlegroups.com
To post to this group, send email to VGLUG@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG