modifying perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting modifying perl script
# 1  
Old 07-06-2009
modifying perl script

Hi freinds
I have a small problem I want u to help me in, I have a syslog server and configured it to send me email automatically, I get a small perl script to help me in, and tested it to send alerts to root and it worked successfully without any problems
Now I want to send it outside, I configured my sendmail to use my email server as SMARTHOST , and tested it by sending email like the following and it delevered successfuly
mail -s test reaky@domain.com -- -r reaky@server.com

Now I tried to use my perl script to use to out side reaky@domain.com, but It doesn't work, the perl script using sendmail -t instead of mail, So what I want to do is modifying this script to use the command: mail -s test reaky@domain.com -- -r reaky@server.com when sending the message

the following is the perl script:
=================================
#!/usr/bin/perl -n
# thanks to Brian Dowling for an example with security in mind.

$TO = 'bassam@tedata.net';
$FROM = $TO;

s/^<\d{1,2}>//;

open(MAIL, "|/usr/sbin/sendmail -t");

print MAIL <<"EOT";
To: $TO
From: $FROM
Subject: SME Log Alert: $_

$_

EOT

close(MAIL);
======================================

Thanks for help

---------- Post updated at 02:50 AM ---------- Previous update was at 02:31 AM ----------

I think we can use something like that
==============
#! /bin/sh
SUBJECT=”SET-EMAIL-SUBJECT”
EMAIL=”mymail@ad.dy”
EMAILMESSAGE=”pathtofile”

echo “This is an email message test” > $EMAILMESSAGE
echo “This is email text” >> $EMAILMESSAGE

/bin/mail -s “$SUBJECT” “$EMAIL”
================
But How to modify EMAILMESSAGE=”pathtofile” , to be input to the script
# 2  
Old 07-06-2009
I would prefer you keep the sendmail program in the script, and instead configure "submit.cf" with your SMARTHOST. You probably configured only "sendmail.cf", but there's very little reason for your server to be handling incoming mail.
# 3  
Old 07-06-2009
I think I know the problem now but I don't know how to solve it
the problem that the sendmail command still using root@localhost.localdomain when sending, Which is rejected
Look to the delevery failier:
==========================
The original message was received at Mon, 6 Jul 2009 11:16:03 +0300
from blackreaper [127.0.0.1]

----- The following addresses had permanent fatal errors -----
<reaky@domain.com>
(reason: 554 mailfrom without country or top level domain is administratively denied)

----- Transcript of session follows -----
... while talking to out.tedata.net.eg.:
>>> MAIL From:<root@localhost.localdomain>
<<< 554 mailfrom without country or top level domain is administratively denied
554 5.0.0 Service unavailable

[-- Attachment #2 --]
[-- Type: message/delivery-status, Encoding: 7bit, Size: 0.3K --]

Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; blackreaper
Arrival-Date: Mon, 6 Jul 2009 11:16:03 +0300

Final-Recipient: RFC822; reaky@domain.comt
Action: failed
Status: 5.0.0
Diagnostic-Code: SMTP; 554 mailfrom without country or top level domain is administratively denied
Last-Attempt-Date: Mon, 6 Jul 2009 11:16:03 +0300

[-- Attachment #3 --]
[-- Type: message/rfc822, Encoding: 7bit, Size: 0.8K --]

Date: Mon, 6 Jul 2009 11:16:03 +0300
To: reaky@domain.com
From: reaky@domain.com
Subject: SME Log Alert: Jul 6 11:15:21 Central.mc.tedata.net/Central.mc.tedata.net sshd[7527]: pam_unix(sshd:session):
+session opened for user amrali by (uid=0)
====================
How to solve this ?
# 4  
Old 07-06-2009
Do you have a submit.cf? If so, post it (as a txt attachment)
# 5  
Old 07-06-2009
Finally I found the problem
The Local_Domain option in sendmail.mc have to be modified , ad it always try to send using it, I changed it and It works now with the same script
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in modifying a PERL script to sort Singletons and Duplicates

I have a large database which has the following structure a=b where a is one language and b is the other and = is the delimiter Since the data treats of language, homographs occur i.e. the same word on the left hand side can map in two different entries to two different glosses on the right... (3 Replies)
Discussion started by: gimley
3 Replies

2. Shell Programming and Scripting

Modifying file from command line using Perl

Hi all, I am having a slight issue updating a file using perl from the command line I need some help with. The item is: DATA_FILE_TYPE=FULL When I run the below command /usr/bin/perl -p -i -e "s/DATA_FILE_TYPE=/DATA_FILE_TYPE=APPEND/g" processfile.cfg It looks to be... (2 Replies)
Discussion started by: kstevens67
2 Replies

3. Shell Programming and Scripting

Need some help modifying script

I have a script that currently runs fine and I need to add or || (or) condition to the if statement and I'm not sure the exact syntax as it relates to the use of brackets. my current script starts like this: errLog="/usr/local/website-logs/error.log" apacheRestart="service httpd restart"... (3 Replies)
Discussion started by: jjj0923
3 Replies

4. Shell Programming and Scripting

Help in modifying existing Perl Script to produce report of dupes

Hello, I have a large amount of data with the following structure: Word=Transliterated word I have written a Perl Script (reproduced below) which goes through the full file and identifies all dupes on the right hand side. It creates successfully a new file with two headers: Singletons and Dupes.... (5 Replies)
Discussion started by: gimley
5 Replies

5. Shell Programming and Scripting

Modifying the Restart Script

Hello, I have a shell script which calls for an existing script with appropriate parameters. It looks something like this. -------------------------------------------------------------------------- #!/bin/bash sh /root/ams_rc stop_shepherd > /dev/null sleep 30 sh /root/ams_rc... (9 Replies)
Discussion started by: Siddheshk
9 Replies

6. Shell Programming and Scripting

modifying file using script

Hi, I am new to shell programming, and want to know is it possible to change the contents of file using script? for example, if want to search 2 words and want to replace these words with 2 new words. Regards, Manoj (4 Replies)
Discussion started by: manoj.solaris
4 Replies

7. Shell Programming and Scripting

Modifying a .ksh script

Hi users, I am on a beginner level and just joined this site. I have created a simple .ksh file in the following manner cat <<EOF >mfile #!/bin/ksh echo "hello world" EOF Request for some help with 2 cases 1. now i would like to add a second line after the first echo command... (4 Replies)
Discussion started by: corbusier
4 Replies

8. Shell Programming and Scripting

Help modifying script to loop through all folders

I have this script someone very kindly help me write last year which loops through all files in a folder and does a command. I need to modify it to loop through all sub-folders of a main folder and only perform the command on files modified after Jan 1st 2008. And I need the command to place the... (3 Replies)
Discussion started by: Fred Goldman
3 Replies

9. Shell Programming and Scripting

need help with understanding and modifying script

hi all, i am new to UNIX. this is my first time using Ubuntu. i need to do this for my fyp. i am using an artificial neural network model to predict the yield strength of steel. the shell script used to execute this model is as shown here: #Thomas Sourmail, Cambridge University /... (4 Replies)
Discussion started by: dakkorn
4 Replies

10. Shell Programming and Scripting

Perl - Appending/Modifying Excel files

Hi I have been using Spreadsheet::ParseExcel and Spreadsheet::WriteExcel to read and write excel workbooks, respectively. Spreadsheet::WriteExcel can only be used for creating new excel spreadsheets. I am looking for a module that would/should help me in appending to existing excel files.... (2 Replies)
Discussion started by: srinivay
2 Replies
Login or Register to Ask a Question