Home | Firestreamer | Downloads | Support | About Us My Account | Site Map | Search | Cristalink RSS Feed  
Firestreamer-RM Getting Started Guide Firestreamer-RM Home

Sample Epilog Script

Below is a sample epilog script that transfers Firestreamer-RM file media to an FTP server. To use the script, follow the steps below.

  1. Save the script as Epilog.cmd, for example, into C:\MyScripts.
  2. Edit the script to change the FTP server address, user name and password.
  3. On the Media Type page of the Firestreamer-RM Wrapper for a file media based scheduled task, enter C:\MyScripts\Epilog.cmd into the Epilog textbox.

@echo off
::
:: Epilog.cmd
:: Epilog script to upload Firestreamer-RM file media to an FTP server.
::

:: Uncomment the below lines to run the script manually from the command prompt for testing purposes.

rem set FSRMTASK_FILEMEDIA=c:\test.fsrm
rem set FSRMTASK_RANDOM=463107D6-EC03-4761-8F4F-B6CE62D1A51A
rem set FSRMTASK_RESULT=c:\result.txt
rem set FSRMTASK_STATUS=ok

::
:: Script parameters.
::

set FTP_SERVER=127.0.0.1
set FTP_USER=user_name
set FTP_PASSWORD=user_password
set FTP_SCRIPT=%TEMP%\%FSRMTASK_BACKUPNAME%.ftp.script.%FSRMTASK_RANDOM%.txt
set FTP_RESULT=%TEMP%\%FSRMTASK_BACKUPNAME%.ftp.result.%FSRMTASK_RANDOM%.txt

::
:: Write the result file header.
::

echo>%FSRMTASK_RESULT% [Result]

::
:: Check the current status of the task and exit if the task has failed.
::

if "%FSRMTASK_STATUS%" == "ok" goto status_ok
if "%FSRMTASK_STATUS%" == "warning" goto status_ok
echo>>%FSRMTASK_RESULT% message=Epilog performed no file transfer as the task failed.
exit 0

:status_ok
::
:: Prepare the FTP script.
::

echo>%FTP_SCRIPT% open %FTP_SERVER%
echo>>%FTP_SCRIPT% user %FTP_USER% %FTP_PASSWORD%
echo>>%FTP_SCRIPT% binary
echo>>%FTP_SCRIPT% put "%FSRMTASK_FILEMEDIA%"
echo>>%FTP_SCRIPT% close
echo>>%FTP_SCRIPT% bye

::
:: Send the file via FTP.
::

ftp -n -s:%FTP_SCRIPT% >%FTP_RESULT%
if errorlevel 1 (
:: Fail the task.
echo>>%FSRMTASK_RESULT% message=FTP failed with exit status=%errorlevel%. Script file: %FTP_SCRIPT%. Result file: %FTP_RESULT%.
echo>>%FSRMTASK_RESULT% status=error
exit 0
)

::
:: Check if the transfer succeeded.
::

findstr /B "226 " %FTP_RESULT%
echo %errorlevel%
if errorlevel 1 (
echo>>%FSRMTASK_RESULT% message=FTP transfer failed. Script file: %FTP_SCRIPT%. Result file: %FTP_RESULT%.
echo>>%FSRMTASK_RESULT% status=error
exit 0
)

::
:: Done.
::

echo>>%FSRMTASK_RESULT% message=FTP transfer succeeded.
echo>>%FSRMTASK_RESULT% status=ok
del %FTP_SCRIPT%
del %FTP_RESULT%
exit 0

 

Terms of Use | Privacy Policy This page is protected by Secure Sockets Layer (SSL) © Cristalink Pty Ltd, 2017. ABN 97615040027