It works well...
I use the SED command added on my Windows computer to manage files
I use the postie exe file to send mails for results
For example... I have a script that backups files from a Windows server to a Linux server
The problem is to select only files containing the date of the day in the file name
The main text script called SCR.TXT contains 2 lines like :
Each night, a batch file do the following job :
1) It replace the AA string with the date of the day
2) It runs winscp.exe to transfer file to other server
3) It sends a mail containing the result of the process
I hope this can help to make nice scripts !
(www.autourdupc.com)
I use the SED command added on my Windows computer to manage files
I use the postie exe file to send mails for results
For example... I have a script that backups files from a Windows server to a Linux server
The problem is to select only files containing the date of the day in the file name
The main text script called SCR.TXT contains 2 lines like :
# Upload SGBD files to remote folder
put D:\files\zip\*AA*.zip /dev/backup/
Each night, a batch file do the following job :
1) It replace the AA string with the date of the day
2) It runs winscp.exe to transfer file to other server
3) It sends a mail containing the result of the process
set yy=%date:~6,4%
set mm=%date:~3,2%
set dd=%date:~0,2%
Rem Replace the string "AA" in the text script with date of the day
sed -e s/AA/%yy%%mm%%dd%/ SCR.TXT > SCRIPT.TXT
Rem Initiate the file transfer
winscp.com /console /script=SCRIPT.TXT
Rem Send result by mail
IF NOT errorlevel 1 (
echo OK
postie.exe -host:HOSTNAME -port:SMTPPort -s:"Backup ended on %COMPUTERNAME%" -to:MAIL_TO -from:MAIL_FROM -msg:"Server %COMPUTERNAME% : \r Process ended : %TIME%"
) ELSE (
echo Error
postie.exe -host:HOSTNAME -port:SMTPPort -s:"Backup failed on %COMPUTERNAME%" -to:MAIL_TO -from:MAIL_FROM -msg:"Server %COMPUTERNAME% : \r Process ended : %TIME%"
)
Rem Give time to the batch process to send the mail
ping -n 10 localhost
I hope this can help to make nice scripts !
(www.autourdupc.com)