LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-22-2005, 04:43 PM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Rep: Reputation: 54
procmail program


I want to design a parser that will parse news articles that come to my news inbox, so I'm learning as I go, for now, all I want is a basic program that will output mail back to the inbox, and write it to file, this is just to get started so I know what works, what does not, etc.

Here's my code so far:

Code:
int main()
{
char a;

fstream fout("/data/samba/shared/ryan/applications/news_parser/procmailtest.log",ios::out);
for(int i=1000;i>0;i--)
{
a = getchar();

cout<<a;

fout.put(a);
}
fout.close(); 

return 0;
}
I can't figure out how to programaticly know when to stop, (I think it has to do with the content-lenght header, but I'm not there yet) so that's why I just read 1000 chars.

My problem is that the email is NOT being outputted to the procmailtest.log file, the file does not even get created. But the email does successfully make it to the inbox. (a little corrupted though, because it ads/removes chars depending on the size of the email but that I know why).

So how do I get it to write the email to file? If I run this program directly and type stuff, it will write the file properly.

I'm also sending emails bigger then 1000 chars to ensure the program does end so the fout.close does get called. I even tried opening and closing a file right at the start and it does not even work either, so really not sure what's going on.
 
Old 05-23-2005, 09:52 AM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
The first obvious question that comes to mind is, does the user you are executing the program as have write access to that directory?
 
Old 05-23-2005, 11:17 AM   #3
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
Yeah, it's running as root (unless it's actually under a different user when procmail runs), and the directory is chmoded 777. Hmm, could it be that it runs under the user to which the mail belongs to? given procmail usually has to write to the home directory, this would make sense.
 
Old 05-24-2005, 06:21 PM   #4
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
That was my problem, had to chmod the folder to 777. Figured it already was since samba is set to chmod everything to 777 but perhaps that folder was created with the shell, I can't remember.
 
  


Reply



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
Problem with mail delivery procmail>cyrus imap (using sendmail,procmail,cyrus,imap) bwana Linux - Software 2 03-24-2005 07:01 PM
Perl Script Program (need) : SpamAssassin-ClamAV-Procmail-Howto cyberjames Slackware 8 01-27-2005 11:53 AM
help with procmail wailm81 Linux - Networking 0 10-15-2004 06:43 PM
Procmail svsalian Linux - Software 0 09-24-2003 08:15 AM
procmail jnsc Linux - Software 3 06-01-2002 11:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 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
Open Source Consulting | Domain Registration