Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Autourdupc

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 :
# 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)
Autourdupc

OK... I understand...

I will try !


Regards,
Laurent.
martin

Re: Pass variables from batch DOS programs to file script SCP

You can easily generate the script with values you need automatically.
Autourdupc

Pass variables from batch DOS programs to file script SCP

Dear,

A nice feature would be the ability to get in the script file the variables defined from the DOS command line...
With this enhancement, you can do some batch jobs and then use the results in SCP scripts.


Best regards to all