9 Replies Latest reply on Apr 1, 2013 11:14 AM by 847750

    Parameters to FDM custom script

      Hi All,

      Can you let me know if we can pass run time parameters to FDM custom script.

      For eg: If we have to delete maps for a certain loacation, instead of taking the location of POV, can we give location name/ ID while executing the script.

      Thanks in advance
        • 1. Re: Parameters to FDM custom script
          Where are you planning to run this script from, if it is from within the FDM web application then your best sticking with the POV settings for things like location, otherwise you will need to maintain some form of parameters file.
          • 2. Re: Parameters to FDM custom script

            I am able to run script through webclient sucessfully by taking POV location settings.

            But, we will be executing scripts through a batch file. So, we need to maintain parameter file..like for eg: if we can pass location name/id as parameter, maps for that particular location should be deleted.

            Can you please advise me how can we go ahead with it.How can I pass parameters to custom script during run time.

            • 3. Re: Parameters to FDM custom script
              Can you post the contents of batch file?
              • 4. Re: Parameters to FDM custom script
                Unfortunately, when running upsShell.exe from a batch file, it is not possible to pass runtime parameters to your script.

                You should also be aware that you cannot determine whether the script was successfully run either - upsShell.exe always returns a 0 exit status.

                To do what you require, your best bet is to either write the parameters to a file and then read the file in your FDM custom script, or create a table in the database, and pass the parameters that way.



                Edited by: 994867 on Mar 19, 2013 11:31 AM
                • 5. Re: Parameters to FDM custom script

                  Below is the custom script

                  strLoc = API.POVMgr.PPOVLocation


                  strSQL="DELETE FROM tDataMap"
                  strSQL = strSQL & " WHERE (PartitionKey = " & strPartKey &")"


                  This script takes POV location and delete maps for that location when executed in web client.

                  I'm trying to execute it through batch by calling script through upsshell.exe. But,it is not working when executed through upsShell.

                  Also, since we cannot refer to POV location in batch,I want to replace it with run time parameter where based on the location ID we enter, maps should be deleted for that location.

                  • 6. Re: Parameters to FDM custom script
                    I know what I'm about to say is not going to make me popular, but ........

                    Skip upsshell and just use a native shell call from your batch .... This is a little more work if you are not completely comfortable with talking to a database; however, if you remove my comments and spaces, there is less than 20 lines of "code". Also, you will need to investigate how you need the connection string to work and considerations about passwords being revealed, etc. Depending on your environment and what exactly you are doing, you can mitigate that..... Food for thought though.

                    Your batch file
                    Set objShell = CreateObject("WScript.Shell")
                    rtnCode = objShell.Run ("FDM_Map_Nuke.vbs " & RES.PlngLocKey)    'rtnCode is the return value as defined in my function below.  This allows you A LOT of flexibility in your batch as you can now handle failures in your data delete call, etc.
                    NOTE: I did not thoroughly test this script out nor am I providing any warranty. While it should be functional, treat it as pseudo-code as you may need to research/tweak it a bit for your purpose.

                    Dim PartitionKey, OdbcDSN, connect
                    On Error Resume Next  'NOTE: For debugging the script, I'd comment this
                    If WScript.Arguments.Count = 1 Then
                        'Get command line paramter
                        PartitionKey = WScript.Arguments.Item(0)
                        'Confirm we have a valid input parameter and bomb if we don't
                        if Err.Number <> 0 or IsNumeric(PartitionKey) = False then wscript.return -1      'This exits script and sends a result code of -1 to the caller program.
                         'Connection String - If you are not familiar with how to make your connection string, visit connectionstrings.com
                        OdbcDSN = "DSN=test;UID=user1;PWD=tttt"
                         'Connect to Database
                        Set connect = CreateObject("ADODB.Connection")
                        'Open Database Connection
                        connect.Open OdbcDSN
                        if Err.Number <> 0 then wscript.return -2      'Now I can see the difference between bad parameter (-1), database connection error (-2)
                        'Nuke records
                        connect.execute "Delete FROM tDataMap where (PartitionKey = " & PartitionKey & ")"
                        if Err.Number <> 0 then wscript.return -3      'Now I can see the difference between bad parameter (-1), database connection error (-2), and Delete (-3) failures 
                       'Close database connection  and release memory
                       Set connect = nothing 
                       Wscript.Echo PartitionKey & " 's data has been cleared from tDataMap successfully!"
                     Wscript.Echo "Usage: FDM_Map_Nuke.vbs PartitionKey"
                     wscript.return -1  'No command line parameter so return invalid parameter error.
                    End If
                    1 person found this helpful
                    • 7. Re: Parameters to FDM custom script
                      Thanks a lot for the reply.Will test the script and let you know the result
                      • 8. Re: Parameters to FDM custom script

                        I have ceated FDM custom script 'testfun' and used same logic as FDM_Map_Nuke.vbs

                        I have created a batch script in fdm server.When I execute batch script, I get below error

                        +'rtnCode' is not recognized as internal or external command+

                        +'RES.PlngLocKey)' is not recognozed as internal or external command+

                        Below is my batch code:

                        Set objShell = CreateObject("WScript.Shell")+
                        rtnCode = objShell.Run ("testfun.css " & RES.PlngLocKey)+

                        Am i missing something here..

                        • 9. Re: Parameters to FDM custom script
                          Any suggestions??