reportbrazil
Technical User
Hi,
I'm having a hard time trying to figure out how to rename a file with the current date, so I can keep back-ups for a daily ftp routine.
Basically I have an output file sent to me every day and I have to ftp this file to a unix server.
I already put toghether the code to do that, as you can see below, but now I need to back-up the file before the ftp, so I'll overrite the file on the server. If anything goes wrong I must be able to re-send the file (maybe days ago).
The ftp part is working fine, even with the PGP encrypt/decrypt for ftp user/passwd protection (sorry for the Portuguese comments on the code...)
Please take a look at my code, which is a frankeinstein, built mostly from tips I've got here (and I've been looking for old answers too)... The next step will be to create a routine for cleansing very old backup files... But I'll get there when the time comes by.
Any help will be very appreciated. Please, don't laugh, I'm really a newby to C, C++, ... My code is almost idiotic #
Tks, Marcelo.
PS: I'm using the freeware dm V.8.28n (Digital Mars C/C++ Compiler) and a bunch of libraries I've got around.
Code below...
#include <stdio.h>
#include <windows.h>
#include <winbase.h>
#include <winsvc.h>
#include <dos.h>
#include <time.h>
#include<conio.h>
// Cria funcao p/ Data
struct date dateFunc()
{
struct date d;
getdate(&d);
return d;
};
void main() // Rotina Principal
{
struct date today;
today=dateFunc(); // Coleta a data atual
printf("%d-%d-%d.out\n",today.da_day, today.da_mon,today.da_year);
struct date novoarq;
// novoarq=("%d, %d, %d.out\n",today.da_day, today.da_mon,today.da_year);
// novoarq=(%d, %d, %d,today.da_day, today.da_mon,today.da_year);
//printf(%s);
{
MSG msg;
HWND hwnd;
system("copy *.out %s" // This is tricky, how do I replace the filename with the current date??
// I get a <whathever_name/variable (i.e %s)> filename here??
// It is working fine from here to the end...
system ("pgpv -z <pass> ftp-in.pgp" /* Desencripta o arquivo de FTP */
printf("\nArquivo de FTP desencriptado\n\n" /* Imprime mensagem */
system ("ftp -i -v -s:ftp-in" /* Envia os arquivos para o eBAN */
printf("\nArquivos transferidos\n\n" /* Imprime mensagem */
system ("del ftp-in" /* Remove o arquivo de FTP */
printf("\nArquivo de FTP desencriptado removido\n\n" /* Imprime mensagem */
// return(0);
}
}
I'm having a hard time trying to figure out how to rename a file with the current date, so I can keep back-ups for a daily ftp routine.
Basically I have an output file sent to me every day and I have to ftp this file to a unix server.
I already put toghether the code to do that, as you can see below, but now I need to back-up the file before the ftp, so I'll overrite the file on the server. If anything goes wrong I must be able to re-send the file (maybe days ago).
The ftp part is working fine, even with the PGP encrypt/decrypt for ftp user/passwd protection (sorry for the Portuguese comments on the code...)
Please take a look at my code, which is a frankeinstein, built mostly from tips I've got here (and I've been looking for old answers too)... The next step will be to create a routine for cleansing very old backup files... But I'll get there when the time comes by.
Any help will be very appreciated. Please, don't laugh, I'm really a newby to C, C++, ... My code is almost idiotic #
Tks, Marcelo.
PS: I'm using the freeware dm V.8.28n (Digital Mars C/C++ Compiler) and a bunch of libraries I've got around.
Code below...
#include <stdio.h>
#include <windows.h>
#include <winbase.h>
#include <winsvc.h>
#include <dos.h>
#include <time.h>
#include<conio.h>
// Cria funcao p/ Data
struct date dateFunc()
{
struct date d;
getdate(&d);
return d;
};
void main() // Rotina Principal
{
struct date today;
today=dateFunc(); // Coleta a data atual
printf("%d-%d-%d.out\n",today.da_day, today.da_mon,today.da_year);
struct date novoarq;
// novoarq=("%d, %d, %d.out\n",today.da_day, today.da_mon,today.da_year);
// novoarq=(%d, %d, %d,today.da_day, today.da_mon,today.da_year);
//printf(%s);
{
MSG msg;
HWND hwnd;
system("copy *.out %s" // This is tricky, how do I replace the filename with the current date??
// I get a <whathever_name/variable (i.e %s)> filename here??
// It is working fine from here to the end...
system ("pgpv -z <pass> ftp-in.pgp" /* Desencripta o arquivo de FTP */
printf("\nArquivo de FTP desencriptado\n\n" /* Imprime mensagem */
system ("ftp -i -v -s:ftp-in" /* Envia os arquivos para o eBAN */
printf("\nArquivos transferidos\n\n" /* Imprime mensagem */
system ("del ftp-in" /* Remove o arquivo de FTP */
printf("\nArquivo de FTP desencriptado removido\n\n" /* Imprime mensagem */
// return(0);
}
}