LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   CYGWIN - sendmail - cronlog - Email issue Linux Windows (http://www.linuxquestions.org/questions/programming-9/cygwin-sendmail-cronlog-email-issue-linux-windows-893174/)

sangal_ak04 07-22-2011 12:32 PM

CYGWIN - sendmail - cronlog - Email issue Linux Windows
 
Hi ALL

Situation:
1. I have written one Linux shell script which uses sendmail command to send a
nice HTML email.
2. This script is written in a sense that it can be used by any product in
Linux platform that my company supports.
3. Now, I want to use this same "global" script to work for any WINDOWS based
product as well that my company supports.

For ex: If my script is giving output as "what's the value of `hostname`" (which is servername), then it's running fine from any Linux product's machine (our company has). Now, to achieve this script to work from ANY WINDOWS based product machine, I want to run the same script which should output "System1" (if my Windows machine name from where I'll run this script is "System1") or blah blah...

To achieve this, I have installed "CYGWIN" and I'm using Mintty session (kind of putty screen, provided when I installed CYGWIN).

Now, when I'm running this script from the WINDOWS machine, this script is working perfectly fine (as expected, as the only line in the script is showing the value of hostname. Here I'm assuming that first line of the script is:
#!/bin/bash and then somewhere i have written, echo `hostname`; in the script).

NOW, the real question that I need.

If I want to add another line in the script to send the output of hostname command ....somehow to my email, I can easily do that. So, I used Linux/Unix "sendmail" command and when I ran it from Linux product machine, It ran perfectly (as expected). Now, I went to Windows - i.e. use CYGWIN Mintty session or any other (Cygwin putty or Cygwin own session), then this "sendmail" command written in the script is showing me an ERROR mesg as listed below:).



/usr/sbin/sendmail is a link to /usr/bin/cronlog.
It is only meant to be called from cron.


Now, I dont understand what's happening here behind the scene. Why Cygwin is not treating Linux sendmail command and running as it's running perfectly when I'm running it on a Linux machine. It's saying setup something in CRON or DO I NEED TO USE SOMETHING ELSE (instead of sendmail), that will run on both Linux and Windows.



Any help / direction is appreciated.

Thanks a lot.


Regards
Arun Sangal

paulsm4 07-24-2011 12:12 AM

Hi -
Quote:

http://cygwin.com/ml/cygwin/2010-07/msg00025.html

So you've installed the cron package and nothing else that provides 'sendmail'.
Take a look at '/etc/postinstall/cron.sh.done' and/or the email archives if
you're curious about the details.
Frankly, if I were in your situation, I probably would have just written something in VBScript and kept two parallel script versions - one for Windows, one for Linux.

But in your case, you probably just need to find, install and configure a mail transport agent (MTA). I understand that "exim" is a very good candidate for use with Cygwin. Google for "cygwin SMTP Exim" and you'll find several hits, including this one:

http://infrablue.tripod.com/cygwin3.html

sangal_ak04 09-25-2012 03:34 PM

I couldn't dig deep into that but got a workaround.

The main purpose of using cygwin was to use shell script and get it running on a Windows environment.

We came up with plan where..

all Linux builds / deliverables (.tar. etc or any file which is a deliverable i.e. output of a build process) ... go to a Linux Shared NAS location called /Some_shared_nas_on_linux/Linux/Project1/BuildArchive/BuildLabel/builddeliverable{1,2,..}.anyextension

similarly, whereever our Windows products were throwing their deliverables, we created such kind of structure on Windows shared NAS as well.. and then, had our Linux guy.. MOUNT that Windows shared NAS on Linux shared nas at the following path.

/Some_shared_nas_on_linux/Windows/Project1/BuildArchive/BuildLabel/builddeliverable{1,2,..}.anyextension

(note this above................^^^ location is actually a mapped/mounted Windows location on linux shared NAS /Some_shared_nas_on_linux/..



That's it. I ran my script from Linux box... no buzz about cygwin anymore as on a file system level, it doesn't matter whether the files have been built by a Linux build process or a windows build process, I just see them and use them for whatever purpose.


All times are GMT -5. The time now is 04:01 AM.