I have a script that addresses and sends an email but I need a body in the message without creating a file and then inserting the file with the standard MAIL commandline.
How can I do that?
Assuming the body you want to create is something you can write to SYS$OUTPUT (e.g. the output of a command procedure or DCL command), then you can use DCL PIPE to pipe the output into VMS Mail, like:
$ PIPE write sys$output "The date is ", f$cvtime() | MAIL SYS$INPUT smith/SUBJ="Piping in DCL"
or
$ PIPE DIR *.LOG | MAIL SYS$INPUT smith/SUBJ="Piping in DCL"
The PIPE command was added in OpenVMS V7.1. If you are somehow on an pre-7.1 system, then your only choice is writing to a temporary file and cleaning up.
Edit: To answer the comment, if you want to eliminate the interactive displays from the Mail command, you can redirect SYS$OUTPUT to NLA0:, as in:
$ PIPE DIR *.LOG | MAIL SYS$INPUT smith/SUBJ="Piping in DCL" > NLA0:
Error messages go to SYS$ERROR, so you'll still see any failures. See HELP PIPE for more goodness.
Have the script create a temporary file to hold the body of the message.
Mail will accept a text file on the command line, like the list of users and the /subj
Related
I am looking for a way using the command line in UNIX to email the results from a grep command.
I am grepping the error logs looking for a "searchword". I temporarily want to email the results to my work account. This is a temporary solution until the SA has the time to write a script that will write it to a file where the file will be read by an automated analyzing program.
sendmail joetester#workemail.com < grep searchword error*
Does anyone have an idea on how to do it that they can share. Thank you.
You want something like grep searchword error* | sendmail joetester#workemail.com, see this question.
I have a list of emails in a txt file that a vendor is requesting to be MD5Hash encrypted. From my understanding MD5Hash isn't an encryption so I'm unsure how to do this.
Is there a terminal command to take a txt file and MD5hash every single email in the file so it is "encrypted"?
The only terminal command I know regarding MD5hash and the result when I MD5hash the file is below:
MD5 -r /Users/Me/Desktop/test_file.txt
Result is:
0240da8148f06ae774de0831eda20eee /Users/Me/Desktop/test_file.txt
Anyone know of a method to (I guess) MD5hash every single email in the file? There are 20k emails, so doing each one individually isn't an option. Or am I misunderstanding how MD5Hash should be used for an email list? And FYI I'm using Terminal on a Mac.
Thanks!
I guess they don't want to transport plain text emails. Later they will compare hashes of their emails to your file.
For examle emails.txt:
a#a.com
b#b.com
c#c.com
d#d.com
Command that writes MD5-s of each e-mail to new file:
cat emails.txt | while read line; do echo -n $line|md5; done >> emailsMd5.txt
If you have a file containing comma separated emails:
cat emailsCommaSep.txt | perl -pe s/,/\\n/g | while read line; do echo -n $line|md5 done >> emailsMd5.txt
Sources:
How to create md5 hash in bash in Mac OS X
hash each line in text file
I am calling a FTP file from DOS, which holds ftp set of commands as follows:
ftp -s:ftpcmd1.txt
Now, the change requirement says, file is to be called multiple times with different file paths.
so, I need to write above statement, each time passing new file path as argument with FTP filename and writing something like "%1" in command inside ftp-file. Please help me with same. How do I do it.
Thanks.
I dont know if we can pass parameter to ftp script (atleast in DOS). But in the above case dynamically written out ftp script file would help. Small bat file which would do that is like below.
echo "user username pwd">ftpcmd1.txt
echo "bin">>ftpcmd1.txt
echo "put %1">>ftpcmd1.txt
echo "bye">>ftpcmd1.txt
ftp -n -i -v servername<ftpcmd1.txt
If you call this bat file with any file name as the first command line argument, it would transfer the file to target servername. Hope this is what you are looking for.
I have some scripts that I didn't write... they search a Squid log database and then create a spreadsheet and email it and then delete the .pid and .xls files it created.
The scripts were using NTLM for one of it's variables (request_user)... I changed it to a manually entered text field.
I don't know perl and the scripts are not working.
The .pid and .xls are getting created but nothing gets emailed and the files don't get deleted (unlink)
Here is are the links to the request and generate files
http://www.the-greenes.net/spreadsheet_request-test.txt
http://www.the-greenes.net/spreadsheet_gen.txt
Can anyone help a limited guy with very limited perl skills?
Thanks
In the spreadsheet_gen script you have this line to setup address to smtp server:
my $mail_server=`10.0.1.98`;
Using backticks make it run command named 10.0.1.98 and assign its output into $mail_server variable. This is most likely wrong, try to replace backticks with regular apostrophes to create string:
my $mail_server = '10.0.1.98';
Can you see any error in your error.log? If $message->send ... fails, it dies with error message and nothing gets sent nor unlinked.
im using procmail to forward emails to different folders in my Maildir.
I use these two lines to get the FROM and TO from the mail, which works pretty fine.
FROM=`formail -x"From:"`
TO=`formail -x"To:"`
These two commands return the whole line without the From: and To: prefix.
So i get something like:
Firstname Lastname <firstname.lastname#mail-domain.com>
Now i want to extract the email between < and >.
For this i pipe the variable FROM and TO grepping it like this.
FROM_PARSED=`echo $FROM | grep -o '[[:alnum:]+\.\_\-]*#[[:alnum:]+\.\_\-]*'`
TO_PARSED=`echo $TO | grep -o '[[:alnum:]+\.\_\-]*#[[:alnum:]+\.\_\-]*'`
But when i print FROM_PARSED into the procmail log by using LOG=FROM_PARSED, i get an empty string in FROM_PARSED and TO_PARSED.
But if i run these commands on my console, all works fine. I tried many other grepping methods, using grep, egrep, sed and even cut (cutting < and >). All working on console, but i use it in procmail it just returns nothing.
Is it possible that procmail is not allowed to use grep and sed commands? Something like a chroot?
I dont get any error logs in my procmail log. I just want to extract the valid email address from the FROM and TO line. Extracting with formail works, but parsing it with grep or sed fails, even if expression is correct.
Could somebody help? Maybe i need to setup procmail somehow.
Strange.
I added this to the users .procmailrc file
SHELL=/bin/bash
The users shell was set to /bin/false, which is correct because its a mail user, no ssh access at all.
You should properly quote "$FROM" and "$TO".
You will also need to prefix grep with LC_ALL=POSIX to ensure [:alnum:] will actually match the 26 well-known characters + 10 digits of the English alphabet.
You already solved this, but to answer your actual question, it is possible to run procmail in a chroot, but this is certainly not done by Procmail itself. Sendmail used to come with something called the Sendmail Restricted Shell (originally called rsh but renamed to remsh) which allowed system administrators to chroot the delivery process. But to summarize, this is a feature of the MTA, not of Procmail.