Before posting, and to avoid disappointment, please read the following:

  • This forum is not for 2BrightSparks to provide technical support. It's primarily for users to help other users. Do not expect 2BrightSparks to answer any question posted to this forum.
  • If you find a bug in any of our software, please submit a support ticket. It does not matter if you are using our freeware, a beta version or you haven't yet purchased the software. We want to know about any and all bugs so we can fix them as soon as possible. We usually need more information and details from you to reproduce bugs and that is better done via a support ticket and not this forum.

Script For Callback Web Page Touch Help!

For technical support visit https://support.2brightsparks.com/
Post Reply
SystemAdmin
Newbie
Newbie
Posts: 4
Joined: Mon May 27, 2019 10:07 pm

Script For Callback Web Page Touch Help!

Post by SystemAdmin »

Can some genius out there please tell me how in this galaxy do I do something like this...

When backup profile completes:
On BACKUP SUCCESS - Call/Open/Get web page like https://website.com/backupsuccess.php
On BACKUP FAIL - Call/Open/Get web page like https://website.com/backupfail.php

I just need a script maybe or some other way of just calling those web pages.
Just need to touch the pages. NOT view them. So that I can log a pass or fail of the current backup to that php service.
SystemAdmin
Newbie
Newbie
Posts: 4
Joined: Mon May 27, 2019 10:07 pm

Re: Script For Callback Web Page Touch Help!

Post by SystemAdmin »

I worked out I can call a batch file that does a 'curl' web page open but that is only if the profile backup is a success.
However how can you get a batch file to read if %PROFILEFAILED% is 1 or 0
Anyone??

The manual says this...
--------------------------------------------------------------------------------------------------------------
https://www.2brightsparks.com/syncback/ ... meters.htm
--------------------------------------------------------------------------------------------------------------
Run after profile: To have a program run after the profile has finished,enable the Run after profile checkbox and type the name into the edit-box or click the folder icon next to it. You can use the same variables and switches as per the Run Before program.

Starting with Windows Vista, Microsoft introduced many restrictions on how programs can react to and handle the shutdown or restart of a computer. Due to these restrictions Run Before and Run After programs will silently fail and not even start if the profile is set to run on shutdown/logoff and the computer is shutdown or restarted (the programs will still be run as per normal if its a logoff).

The special variable %PROFILEFAILED% can be used to pass the result of the profile run. If the value is 1 (one) then the profile failed (or was aborted), if the value is 0 (zero) then the profile run was a success.
--------------------------------------------------------------------------------------------------------------
SystemAdmin
Newbie
Newbie
Posts: 4
Joined: Mon May 27, 2019 10:07 pm

Re: Script For Callback Web Page Touch Help!

Post by SystemAdmin »

Anyone ??
SystemAdmin
Newbie
Newbie
Posts: 4
Joined: Mon May 27, 2019 10:07 pm

Re: Script For Callback Web Page Touch Help!

Post by SystemAdmin »

Someone else said I would never get a reply in the forum - guess that was correct..
mickyj
2BrightSparks Staff
2BrightSparks Staff
Posts: 470
Joined: Mon Jan 05, 2004 6:51 pm

Re: Script For Callback Web Page Touch Help!

Post by mickyj »

Hi, you're unlikely to get a reply for creating a custom script as that can be a lot of work.

The script below should work:

- Copy the code below to a text file and save it as OpenWebPage.bas
- Run SyncBack and install the script and then enable it
- Modify your profile, go to the Scripts tab and select the "Open web page after a profile run" then click Apply
- Go to the Open Web Page and enter the URL's to go to on success and/or failure

This doesn't open a web browser. It just visits the page and saves the page to the debug log, if debugging is enabled. This is just so you can check if it works. From the quick tests I did it appears to work.

Code: Select all

'
' Example script for 2BrightSparks SyncBackPro V8 that opens a web
' page after a profile runs (if the run is simulated then it does not).
'
' SBLang=Basic
'
' http://www.2BrightSparks.com/
'

'-----------------------------------------------------------------------------
'-DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING !-
'-----------------------------------------------------------------------------

'
' This is a profile configuration and runtime script 
'
Function Description(ByRef ScriptType)
  Description = "Open web page after a profile run"
  ScriptType = SCRIPTTYPE_RUN + SCRIPTTYPE_CONFIG
End Function

'
' This routine is called after the profile has finished.
'
Sub RunProfileResult(ProfileResult, ErrMsg)
  Dim oXMLHTTP
  Dim sResult
  Dim OpenPage
  Dim URLToUse, SuccessURL

  ' If simulated, do nothing
  If SBRunning.Simulated then
    Exit Sub
  End If

  ' Get profile result
  OpenPage = True
  Select Case ProfileResult
  Case 0
    ' 0 = No result (ELR_None)
    OpenPage = False
  Case 1
    ' 1 = Unknown profile (ELR_UnknownProfile)
    OpenPage = False
  Case 2
    ' 2 = Profile is already running (ELR_AlreadyRunning)
    OpenPage = False
  Case 3
    ' 3 = Profile has been imported and not run yet (ELR_Imported)
    OpenPage = False
  Case 4
    ' 4 = Profile is running (ELR_Running)
    OpenPage = False
  End Select

  ' Are we going to open a web page?
  If OpenPage = False then
    Exit Sub
  End If

  ' Which URL to use?
  SuccessURL = SBVariables.GetProperty("SuccessURL", "", FALSE)
  URLToUse = SBVariables.GetProperty("FailureURL", "", FALSE)
  Select Case ProfileResult
  Case 11 ' ELR_RestSuccess
    URLToUse = SuccessURL
  Case 14 ' ELR_Success
    URLToUse = SuccessURL
  Case 30 ' ELR_IntegrityCheckSuccess 
    URLToUse = SuccessURL
  End Select

  ' Nothing to do?
  if URLToUse = "" then
    Exit Sub
  End If

  ' Open page
  set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
  oXMLHTTP.open("GET", URLToUse, false)
  oXMLHTTP.send
  sResult = oXMLHTTP.responseText
  SBRunning.DebugOut(URLToUse, sResult, 1)
  Set oXMLHTTP = nothing
End Sub

'
' Configuration part of the script
'

' Not for group profiles, and only display setup page if the profile
' is using the script.
Function ConfigWantSetupNode(IsGroup)
  ConfigWantSetupNode = not IsGroup and SBProfile.UsesScript
End Function

' Reset to factory defaults
Sub ConfigFactoryDefaults
  SBVariables.DeleteProperty("SuccessURL")
  SBVariables.DeleteProperty("FailureURL")
End Sub

' Always allow the setup page to close
Function ConfigCanClose
  ConfigCanClose = TRUE
End Function

' Can revert to factory settings
Function ConfigCanRevert
  ConfigCanRevert = TRUE
End Function

' Setup node caption
Function ConfigNodeCaption
  ConfigNodeCaption = "Open Web Page"
End Function

' Create setup window display
Sub ConfigSetupDisplay
  SBProfile.AddLabel("Enter the URL of the pages to open on success or failure of the profile", 1)

  SBProfile.AddEdit("Success URL", 128, FALSE, FALSE, 2)
  SBProfile.AddEdit("Failure URL", 128, FALSE, FALSE, 3)
End Sub

' Load settings. Return error message on failure.
Function ConfigLoadSettings
  ConfigLoadSettings = ""

  SBProfile.SetEdit(SBVariables.GetProperty("SuccessURL", "", FALSE), 2)
  SBProfile.SetEdit(SBVariables.GetProperty("FailureURL", "", FALSE), 3)
End Function

' Save settings. Return error message on failure.
Function ConfigSaveSettings(Silent)
  ConfigSaveSettings = ""
 
'  if SBProfile.GetEdit(2) = "" then
'    ConfigSaveSettings = "The Success URL cannot be empty!"
'    Exit Function
'  end if

'  if SBProfile.GetEdit(3) = "" then
'    ConfigSaveSettings = "The Failure URL cannot be empty!"
'    Exit Function
'  end if

  SBVariables.SetProperty("SuccessURL", SBProfile.GetEdit(2))
  SBVariables.SetProperty("FailureURL", SBProfile.GetEdit(3))
End Function

' The settings have changed
Sub ConfigUpdateConditionals
End Sub
Post Reply