Navigation: Scripting Reference Manual > Functions & Subroutines > IPCDeleteRemoteFile

 

IPCDeleteRemoteFile

 

Contact Us: fredsupport@photonengr.com

 

Description

This function initiates a request to delete a specific file (no wildcards) from each remote node.

 

 

Syntax

count = IPCDeleteRemoteFile( connections(), fileName )

 

 

Parameters

count (Long)

Returned number of successfully initiated file delete operations.  This does not indicate the number of successfully deleted files.

 

connections() As T_IPCINSTANCE

An array of T_IPCINSTANCE structures, with each structure defining the connection information for a remote node.

 

fileName As String

The name of the file whose deletion is being initiated on the remote nodes.  If fileName does not include a full path specification, then the file will be searched for in the local working directory of each remote node.

 

 

Example

The example below demonstrates how to to load the connections() array with remote node connection information stored in a configuration file and then go through a series of connect, query and reconnect commands before finally terminating the remote FRED instances.  Note that in this example only 2/3 connections are active and that the detailed status listing indicates that only 1/2 active nodes successfully deleted the requested file.

 

Sub Main

 

    EnableTextPrinting(True)

    ClearOutputWindow()

 

    'Use a CSV file to populate the connections array

    Dim nRemoteLoad As Long

    Dim connections() As T_IPCINSTANCE

    Dim configFile As String, configLocation As String

    configLocation = GetDocDir() & "\"

    configFile     = "DCTestBed_Connections.csv"

    nRemoteLoad    = IPCLoadConfigFile( connections(), configLocation & configFile )

 

    'Connect to the remotes

    Dim nConnect As Long

    nConnect = IPCConnect( connections() )

 

    'Wait for UP TO two minutes for the remotes to become idle

    Dim nWait As Long

    nWait = IPCWaitForIdle( connections(), "2m" )

 

    'Query the status of the connections

    Dim nQuery As Long

    nQuery = IPCQueryStatus( connections(), "detail" )

 

    'Delete a remote file

    Dim nDel As Long

    nDel = IPCDeleteRemoteFile( connections(), connections(0).base_dir & "\test_file.txt" )

 

    'Disconnect from the remote nodes and save a snapshot file of the connections array

    Dim nDisconnect As Long

    Dim snapShot As String

    snapShot    = configLocation & "DCTestBed_Reconnect.csv"

    nDisconnect = IPCDisconnect( connections(), snapShot )

 

    'Now reconnect

    Dim nReconnect As Long

    nReconnect = IPCReconnect( connections(), snapShot )

 

    'Query the status again

    nQuery = IPCQueryStatus( connections(), "detail" )

 

    'Terminate the connections

    Dim nTerminate As Long

    nTerminate = IPCTerminate( connections(), "sterilize", "1d" )

 

 End Sub

 

The example code above produces the following content in the FRED output window:

 

[MASTER]IPCLoadConfigFile:  3 of 3 connections read from 'C:\temp\DCTestBed_Connections.csv'                                                  

                    index          active                    speed          host                              status

                    1          false                    100          computer1                    ---

                    2          true                    100          computer2                    ---

                    3          true                    100          computer3                    ---

                                                            

                                                            

[MASTER]IPCConnect:    2 of 3 Remote FRED instances connected                                                            

                                                            

          index          host                    result                              message

          1          computer1          inactive                    ---

          2          computer2          connected                    ---

          3          computer3          connected                    ---

                                                            

                                                            

[MASTER]IPCWaitForIdle:  2 of 2 active connections are idle (0 sec)                                                            

                                                            

                                                            

[MASTER]IPCQueryStatus:  3 connections queried                                                            

                                                            

          index          host                    message                    

          1          computer1          inactive                    

          2          computer2          idle                    

          3          computer3          idle                    

                                                            

          index          host handle          cmd handle          message

          2          NI_00000019           HPOL                    check

                                         PING                    

                                         IDLE                    idle

          3          NI_00000020           HPOL                    check

                                         PING                    

                                         IDLE                    idle

                                                            

                                                            

[MASTER]IPCDeleteRemoteFile:  2 of 2 active nodes queued for file delete:  'C:\Users\Public\Documents\Fred_Remote\test_file.txt'                                                            

                                                            

[MASTER]IPCDisconnect:  2 of 3 Remote FRED instances disconnected but still running                                                            

                                                            

          index          host                    message                    

          1          computer1          inactive                    

          2          computer2          disconnected                    

          3          computer3          disconnected                    

                                                            

                                                            

[MASTER]IPCReconnect:  2 of 3 Remote FRED instances reconnected                                                            

                                                            

          index          host                    message                    

          1          computer1          inactive - reconnect not attempted                    

          2          computer2          reconnected - idle                    

          3          computer3          reconnected - idle                    

                                                            

                                                            

[MASTER]IPCQueryStatus:  3 connections queried                                                            

                                                            

          index          host                    message                    

          1          computer1          inactive                    

          2          computer2          idle                    

          3          computer3          idle                    

                                                            

          index          host handle          cmd handle           message

          2          NI_00000021           HPOL                      check

                                         PING                    

                                         IDLE                     idle

                                         OP_00000000           finished

          3          NI_00000022           HPOL                 check

                                         PING                    

                                         IDLE                     idle

                                         OP_00000000           failed:  could not find file 'C:\Users\Public\Documents\Fred_Remote\test_file.txt'

                                                            

                                                            

[MASTER]IPCTerminate:  2 of 3 Remote FRED instance terminations initiated                                                            

                                                            

          index          host                    message                    

          1          computer1          inactive                    

          2          computer2          initiated                    

          3          computer3          initiated                    

                                                  

 

 

See Also

Distributed Computing Script Commands

T_IPCINSTANCE

 

 

 

 

 

Copyright © Photon Engineering, LLC