Skip to main content

Problem:

Here is an example of calling the Fileshare Manager API to shutdown or restart a fileshare server.

Note that security must be turned in fileshare to do this.

Resolution:

       Program-ID.  fsmanager.

       Working-Storage Section.

       01  fsmgr-param-block.

           05  fsmgr-function-code         pic x(02) comp-x.

           05  fsmgr-error-status          pic x(02) comp-x.

           05  fsmgr-fileshare-name        pic x(16).

           05  fsmgr-supervisor-passwd     pic x(20).

           05  fsmgr-reserved              pic x(24).

       01  ws-command-line                 pic x(256).

       01  ws-function                     pic x(20).

       Procedure Division.

       0000-Main.

           accept ws-command-line from command-line.

           if ws-command-line = space

               perform 9000-Usage

           end-if.

           unstring ws-command-line delimited by space into

               ws-function

               fsmgr-fileshare-name

               fsmgr-supervisor-passwd

           end-unstring.

           move function upper-case(ws-function) to ws-function.

           evaluate ws-function

               when 'CLOSE'

                   move 4 to fsmgr-function-code

                   perform 1000-Call-FSMgr

               when 'RESTART'

                   move 5 to fsmgr-function-code

                   perform 1000-Call-FSMgr

               when other

                   perform 9000-Usage

           end-evaluate.

           perform 9999-Terminate.

       1000-Call-FSMgr.

           call 'fsmgr' using fsmgr-param-block.

           evaluate fsmgr-error-status

               when 0

                   display "Command completed successfully"

               when 1

                   display "Communications Error: "

                       fsmgr-fileshare-name

                   display "could not be contacted..."

               when 2

                   display "File error during initial connection."

               when 3

                   display "Invalid password specified."

               when 4

                   display "Invalid function."

               when 5

                   display "No Fileshare log file."

               when 6

                   display "Function 2 or 3 could not complete."

               when 10

                   display "Other error."

               when other

                   display "Unknown error."

           end-evaluate.

       9000-Usage.

           display

               "Usage: fsmanager <CLOSE|RESTART> <Server> <Password>".

           perform 9999-Terminate.

       9999-Terminate.

           goback.

Old KB# 2136

#ServerExpress
#RMCOBOL
#COBOL
#AcuCobol
#netexpress