Log file through email or ftp

This is a discussion on Log file through email or ftp within the C++ Programming forums, part of the General Programming Boards category; I have a console program that saves a log file in same directory that the .exe is in. I want ...

  1. #1
    OpX
    OpX is offline
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Question Log file through email or ftp

    I have a console program that saves a log file in same directory that the .exe is in. I want to know if there is a way to either upload this file to an ftp server or send it to an emial every such amount of time.

    Thanks,
    OpX

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    I'm sure there are many ways of doing it, but we need to know which OS/Compiler you're using.

    Does your exe keep the log file open? If so, this might prevent other programs from being able to read it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    OpX
    OpX is offline
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Right now I am using M$'s Visual C++ 2010 express junk and Win7 Ultimate 64bit. No, my program does not keep the log file open

  4. #4
    Registered User \007's Avatar
    Join Date
    Dec 2010
    Posts
    179
    - Socket programming
    - SMTP

    I wouldn't rely on external programs to do the work for you.. just code it into your main program.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    OpX
    OpX is offline
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    I don't know if I was being clear enough. I want my program to send the file automatically every X amount of minutes/hours etc.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    FTP Library + timer. Not difficult at all.
    How to make a timer? The easiest is just a separate thread + sleep. Sleep depends on OS. Sleep for Windows, sleep or such on Linux.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    OpX
    OpX is offline
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Quote Originally Posted by Elysia View Post
    FTP Library + timer. Not difficult at all.
    How to make a timer? The easiest is just a separate thread + sleep. Sleep depends on OS. Sleep for Windows, sleep or such on Linux.
    Do you have any example code you could show me? Sleep for Windows btw

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    There is already an example for the ftp library.
    Other than that, you would just do
    Code:
    // Upload stuff
    Sleep(5000); // Sleep 5 secs
    // Repeat
    Don't forget to include windows.h to use Sleep.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Leak in AppWizard-Generated Code
    By jrohde in forum Windows Programming
    Replies: 4
    Last Post: 05-19-2010, 04:24 PM
  2. Can you help me about tolower() in file
    By nctar in forum C Programming
    Replies: 7
    Last Post: 05-12-2010, 10:04 AM
  3. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  4. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21