Modify a program to accept an email address where the output will be sent - perl

I am developing a Perl script which should take an email address as a parameter. The entire output of the script should be sent to that address as well as printed in screen. Any suggestions?
./script -mail xyz#gmail.com
Actually I already have a script which is currently printing information about memory utilization of instances, logging information etc. I need to add functionality to that script so that the output is mailed to the address provided as a parameter.
The output is something like
memory: 234.3 MB CPU: ...
and other stats. I want to run my script like
./script -mail xyz#gmail.com
and send all output to this email address as well as displaying it on screen.

You haven't shown us what you have tried so far, so don't expect anyone to give you too much help. But here are a couple of pointers.
If you are having problems defining and parsing command line options (like --mail) then see the standard Perl module Getopt::Long.
If you're having trouble creating and sending email then see the CPAN modules Email::Sender or Email::Stuffer.

Related

Check email in shell. And make it look good

I want to output the email information as
(Who it's from)
(Subject)
Here's the code i found on the internet
#!/bin/sh
curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if /<name>/; print "$2\n" if /<(title|name)>(.*)<\/\1>/;')
however this isn't the format i want it and i don't know any perl.
i was wondering if i could either output the perl information to a shell variable so i can edit the layout. or output the perl information to a txt file and then edit it then. by edit i mean change the order of it so its name, subject rather than subject, name. Any help will be a big help. I may be completely wrong because i don't know any perl.
Assuming you are logged in to Gmail, https://mail.google.com/mail/feed/atom will give you an dump of the latest few messages in your inbox. This is in XML (Atom) format and you can use whatever you want to read it. You can see what the raw data looks like by going there in a browser.
The code you have found uses Perl to parse and display a more readable form of this data. You are certainly not obligated to use Perl if you don't know it, so you can use whatever programming language you are familiar with.

Send Ctrl+Z to serial port via command line

I am trying to send the following to the COM1 serial port via command line using ECHO or similar (I've also tried downloading a small program called serialsend, but I am stuck with how to send the equivalent of CTRL+Z. This is to send a SMS message via a Siemens TC35 GAM module. I am able to do it via Hyperterminal as a test and it works fine, but I cannot figure out how to send the CTRL+Z at the end to confirm the ned of the message.
This is what I have:
AT
AT+CMGF=1
AT+CMSG="+xxxxxxxxxxx"
HELLO
Now, after Hello, which is the message I want to send, I have to send CTRL+Z. But cannot figure out how to do it, I have tried this:
AT
AT+CMGF=1
AT+CMSG="+xxxxxxxxxxx"
HELLO
\x1A
As I read somehwere that this would be the equivalent of doing it, but it hasnt worked.
Can anyone help me with this? I have found solutions, but they are not command line, which is what I need.
I have also tried using this format:
ECHO AT > COM1:
But as I don't know how to send CTRL+Z I don't know if it is working.
I wrote the free command line program SerialSend that you mentioned. Since this question was originally posted, I've added an extra feature that allows arbitrary byte values to be included (in hex format) in the text you're sending via the serial port. For example, to send Ctrl-Z (26 decimal, 0x1A hex), just use the following command:
SerialSend /hex "\x1a"
Port name/number, baudrate, etc can be configured with additional command line arguments. For example,
SerialSend /baudrate 9600 /devnum 2 /hex "\x1a"
For more details, see the SerialSend home page.
Hope that helps!
Ted
Use this:
port.Write(txt_msgbox.Text + char.ConvertFromUtf32(26));
It works :)
type this command Serial.println((char)26); in Arduino code ... one square box will appear on serial monitor. Copy that square and paste in Notepad++. It will be displayed as SUB with black background. wheneever you want to type cntrl+z, just copy this SUB and paste in serial monitor. It works.

How can I open multiple attachments of the same name in an email, then move the sender of the attachment to a spreadsheet?

I have an internship and was recently assigned the tedious task of cleaning the email lists. My employer has sent me a series of email with email bounces as attachments, many at a time, all with the same name. I have considered ways of doing this most efficiently, I'm looking to avoid just clicking through like a slave. My thoughts were to create a macro using autohotkey's language, but I feel like maybe a batch file or some sort of Perl might do the same thing. Could anybody give me an idea as to how to do this, specifically with a batch file? Thanks in advance!
Mail::DeliveryStatus::BounceParser parses bouncing email addresses out of delivery report messages.
If you don't know any perl, then I recommend that you first convert the mailbox into some format that stores each email in separate text files, like MH or similar.
At that point, you can trivially use the command grep _pattern_ | sed -e 's/:.*//' | sort | uniq > _list_ to obtain lists of all files matching _pattern_. You may inspect/edit this file _list_ to verify that the desired results were obtained.
You may then create another director junk or whatever and move all the files listed in _list_ into junk with a command like perl -e 'chomp; rename($_,"junk");' < _list_.
If you'll need this regularly, then you could automate this further, likely using perl alone, but a one off task will probably involve more messing about with getting the right message list.
Alternatively, you could load all the emails into a single folder in an sane mail reader, like Mac OS X's Mail.app, and do simply search, select all, move/delete commands.

Parsing syslogs with Perl using a named pipe?

I'm trying to write a script that will grab logs across a network and parse them for relevant information and perform some action (email if there's a critical issue, simply write to a log file if its a warning). I am using an AIX machine with syslogd to process the logs. Right now it is performing like usual, writing all logs to files ... a lot of files.
I was advised to use Perl and Named Pipes to implement the script. I've just spent some time reading up on named pipes and I find them quite fascinating. However, I'm stumped as to how the "flow" of information should work in this situation and how to make perl handle it.
For example, should I create a fifo outside of the script and tell syslogd to write to it by default and have my script on the other end parsing it? Can Perl do that and (for you sysadmins) is this a smart/possible option?
This is my first encounter with Perl and with named pipes.
You can surely create a named pipe in Perl, although it seems to me that for what you are trying to do, it is better to create the named pipe outside of perl, as you are suggesting, and then have syslogd write to it, and read the pipe from perl.
I don't know very well AIX, but this could do for creating a pipe (source):
mkfifo -p /var/adm/syslog.pipe
To have syslogd write to it, define this in /var/adm/syslog.pipe:
*.info |/var/adm/syslog.pipe
Then:
kill -HUP `cat /var/run/syslogd.pid`
You could also put all this stuff into your perl script: in case the pipe did not exist or syslogd were not using it, the script would arrange all required things for you.
Possibly you could provide some more details as to what you are trying to do, if you need more help.

Powershell - MS Exchange E-mail Autoresponder

We've currently got an issue where we're receiving a lot of bounced e-mails (from an auto generated e-mail) back from people where a specified e-mail address is not valid (failure notice). I need to identify certain messages in the mailbox and respond automatically to them - as a newbie to Powershell I'm struggling a bit! I think I understand how to check for the occurrence of a string but I don't know how to iterate through an inbox to look at/get a handle on each message in turn and I don't know how to extract the subject or body text in order to analyse the contents and perform a string comparison. I fear this should be easy - but I can't find anything on the web that might do the job - can anyone help?
So just to clarify what you're looking for.
Mailbox A receives a large number of failure notice/bounce messages.
You'ld like your powershell script to search Mailbox A for every instance where the Subject line (or message body) contains "String X" and if there is a match, take some action?
Also, what version of Exchange are you using? You need to be at least on 2007 to use Exchange Command Shell. You'll then want to look over the Command Shell commands that can be run.
Look at the Exchange Message Tracking Log, and Pipe the results from one command you run to the next. Think of it like this...
(Run a command) | (Run another command on the results of the first command) | (Run a last command on the results of the second).
You can view an example on my website at:
http://www.technoctopus.com/?p=223
While not exactly the same, it might get you moving in the right direction.