The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sendmail 8.11 jgt UNIX and Linux Applications 1 04-13-2008 12:34 PM
sendmail.cf robsonde UNIX for Dummies Questions & Answers 0 01-28-2008 12:21 PM
rsh commands not getting executed from Solaris 10 System to AIX System jumadhiya SUN Solaris 25 01-22-2007 02:26 AM
Taking a system off a network on a system Terrible Shell Programming and Scripting 4 12-25-2006 06:49 AM
what is sendmail ? how to use it ? vkandati UNIX for Dummies Questions & Answers 4 03-15-2005 08:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-10-2005
Registered User
 

Join Date: Aug 2005
Posts: 3
using sendmail in system(cmd)

In 'C' I am trying to use the sendmail to send a message that program completed successful or failed.

The syntax is:
sprintf(cmd,"/usr/sbin/sendmail roncayenne@ssss.org to: roncayenne@ssss.org from:root subject: PROGRAM SUCCESSFUL .");
system(cmd);

But this is not working. Seems it does not like anything after the sendmail address and does not recognize the period at the end.
Anyone know what is wrong with the above. Thanks!

Ron
Reply With Quote
Forum Sponsor
  #2  
Old 08-10-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,264
sendmail will work but we use a simpler way -- mailx:
Code:
EmailId = string which is email address
textfile can be empty or have message text in it - the file must exist
    and be referenced by a pathname -- strcpy(textfile,"/path/to/textfile");
    
sprintf (cmd, "/usr/bin/mailx -s '%s' %s < %s", "Status Report", EmailId,textfile);
system (cmd);
This sends the mail as the current owner of the process.
Reply With Quote
  #3  
Old 08-10-2005
Registered User
 

Join Date: Aug 2005
Posts: 3
I sure wish we had mailx on our box but we don't so I am trying to get the sendmail to work. Any ideas on the syntax that would be similar to what you showed on mailx?
Thanks for the info and the reply...
Reply With Quote
  #4  
Old 08-10-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,264
This was tested and works on HPUX:
Code:
#include <stdlib.h>
int main()
{
    char message[24]={0x0};
    char cmd[128]={0x0};
    const char *EmailId="jmcnama@piffl.com";
    strcpy(message,"all is well");
    sprintf(cmd, "echo \"%s.\" | sendmail %s ",message,EmailId);
    system(cmd);
    return 0;

}
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0