LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2008, 07:38 AM   #1
npereira
LQ Newbie
 
Registered: Oct 2003
Posts: 26

Rep: Reputation: 15
Trying to send mail from cygwin


Hi all,

I'm having a delima. I'm trying to send mail from cygwin. I installed cygwin and exim as I read that exim was the replacement of sendmail in a windows environment.

What I'm trying to do is build a script that will SSH to a box on the local lan, execute a command and print out to a txt file the output of that command, then log out, and send this txt capture to an email.

How can I achieve this?

Thanks in advance for your help.
 
Old 03-18-2008, 07:47 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
First exim is not designed for windows, it is a sendmail replacement on *nix machines.

To do what you want you do not need to write to a text file you can pipe the output of your command to the mail directy with out going to file, "the beauty of *nix"

Code:
ssh host 'command | mail -s "This is the output' someone@somedomain.ext'
 
Old 03-18-2008, 07:55 AM   #3
npereira
LQ Newbie
 
Registered: Oct 2003
Posts: 26

Original Poster
Rep: Reputation: 15
that's good, although when I type mail, I get :
$ mail
bash: mail: command not found

Quote:
Originally Posted by datopdog View Post
First exim is not designed for windows, it is a sendmail replacement on *nix machines.

To do what you want you do not need to write to a text file you can pipe the output of your command to the mail directy with out going to file, "the beauty of *nix"

Code:
ssh host 'command | mail -s "This is the output' someone@somedomain.ext'
 
Old 03-18-2008, 07:59 AM   #4
npereira
LQ Newbie
 
Registered: Oct 2003
Posts: 26

Original Poster
Rep: Reputation: 15
This is what I need to do:

telnet 192.168.1.1
it will ask for a password, I want the script to enter it on it's own
then type the command: sh sipd realms
output this to text and email it to a user account.

Quote:
telnet 192.168.1.2
password:
SBC1> sh sipd realms PEER-GC-FAX
06:55:44-59
This is the output to print to text
Quote:
Realm PEER-GC-FAX() [In Service]
-- Period -- -------- Lifetime --------
Active High Total Total PerMax High
Inbound Sessions 35 39 17 22243 64 197
Rate Exceeded - - 0 0 0 -
Num Exceeded - - 0 0 0 -
Burst Rate 0 5 0 0 0 24
Reg Rate Exceeded - - 0 0 0 -
Reg Burst Rate 0 0 0 0 0 0
Outbound Sessions 4 5 3 3691 27 46
Rate Exceeded - - 0 0 0 -
Num Exceeded - - 0 0 0 -
Burst Rate 0 3 0 0 0 24
Reg Rate Exceeded - - 0 0 0 -
Out of Service - - 0 0 0 -
Trans Timeout 0 0 0 0 0 0
Requests Sent - - 49 57833 143 -
Requests Complete - - 48 57833 141 -
Seizure - - 3 3691 27 -
Answer - - 2 3278 23 -
ASR Exceeded - - 0 0 0 -
Requests Received - - 62 75110 152 -
Latency=0.093; max=0.277
Then exit
Quote:
SBC1> exit
Closing Session


Connection to host lost.

user@NetSup09 ~
$
Then email the output screen of the command

Last edited by npereira; 03-18-2008 at 08:02 AM.
 
Old 03-18-2008, 08:33 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Is the remote machine *NIX or Windows?
 
Old 03-18-2008, 10:33 AM   #6
npereira
LQ Newbie
 
Registered: Oct 2003
Posts: 26

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by unSpawn View Post
Is the remote machine *NIX or Windows?
The system running the script (which I am setting up right now) will be CentOS 5.1
The remote system is a session border controller... (SBC). management is all CLI based.
 
Old 03-19-2008, 07:15 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by npereira View Post
The remote system is a session border controller... (SBC). management is all CLI based.
I'm asking because I'm wondering what it provides in terms of OS functionality. If it already has SNMP for instance it would be easier to set up a custom command so you can poll for info from the LAN-facing side. If you want to telnet in automagically the first thing comes to mind is using an "expect" script. Searching LQ should yield info and examples.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command line email client to send mail to remote mail server dhanju Linux - Software 1 03-07-2008 07:37 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 11:40 PM
with the linux proxi, backend pop3 mail client can not receive mail and send mail rubin823 Linux - Networking 0 12-21-2006 11:06 PM
Unable to send mail to some mail servers due smtp greetings malformed atotomex Linux - Networking 6 12-20-2005 05:38 PM
Server does'nt send mail until shutdown and LAN can't send or receive. Wolfy Linux - Networking 0 08-02-2004 08:31 PM


All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration