Top
Systemwalker Runbook Automation Reference Guide
Systemwalker

3.15.6 File Library

The file library provides the following classes:

Article number/class name

3.15.6.1 File Transfer

3.15.6.2 Changing File Access Permissions

3.15.6.3 File Existence Confirmation

3.15.6.4 File Making/File Deletion

3.15.6.5 Adding String to Files

3.15.6.6 File Copy/File Move

3.15.6.7 File Compression/File Decompression

3.15.6.8 Character Code Conversion

3.15.6.9 Searching String in File

3.15.6.10 Replacing String in File

3.15.6.1 File Transfer

Class Name

Swrba_File

List of Methods

Method

Description

String receive_file(String hostname, String username, String password, String source, String destination, String ostype)

Acquire the file from the specified host.

"Success" is returned if acquisition was successful.

An exception is returned if acquisition failed.

String send_file(String hostname, String username, String password, String source, String destination, String ostype)

Transfer files to the specified host.

"Success" is returned if transfer was successful.

An exception is returned if transfer failed.

Integer return_code()

Return the return value of the file acquisition/transfer results.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host acquiring or transferring the file.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host acquiring or transferring the file.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
source	Specify the name of the file that is the acquisition source.
destination	Specify the name of the file that is the acquisition destination.
ostypeSpecify the operating system of the host acquiring or transferring the file.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.2 Changing File Access Permissions

Class Name

Swrba_File

List of Methods

Method

Description

String change_file_authority(String hostname, String username, String password, String execusername, String execpassword, String filename, String ownerauthority, String groupauthority, String otherauthority, String ostype)

Change the access permissions for the file on the specified host.

"Success" is returned if access permissions were changed successfully.

An exception is returned if access permissions failed to be changed.

Integer return_code()

Return the return value of the results of changing access permissions.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host where the file whose access permissions are to be changed resides.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host where the file whose access permissions are to be changed resides.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
filename	Specify the name of the file whose access permissions are to be changed.
ownerauthoritySpecify the access permission for the owner of the file. Specify execute (X), read (R), write (W), or cancel all (C) permissions.
If the access permissions for a file are changed using the file transfer infrastructure and the file is in a Windows environment, the file attributes will be changed.
groupauthority	Specify the access permission for the group that owns the file. Specify execute (X), read (R), write (W), or cancel all (C)permissions.
If the access permissions for a file are changed and the file is in a Windows environment, the specified content does not take effect.
otherauthoritySpecify the access permission for other users of the file. Specify execute (X), read (R), write (W), or cancel all (C)permissions.
If the access permissions for a file are changed and the file is in a Windows environment, the specified content does not take effect.
execusername	Specify the name of the user whose file access permissions are to be changed.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpassword	This library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.
ostypeSpecify the operating system of the host where the file whose access permissions are to be changed resides.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope//bin/parts/lib/standard/swrba_file.rb

3.15.6.3 File Existence Confirmation

Class Name

Swrba_File

List of Methods

Method

Description

String search_file(String hostname, String username, String password, String filename, String ostype, String execusername, String execpassword)

Confirm whether the specified file exists in the specified host. "Success" is returned if the file existence confirmation is successful.

An exception is returned if the file existence confirmation failed.

Integer return_code()

Return the return value of the file existence confirmation results.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host confirming the existence of the file.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host confirming the existence of the file.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
filenameSpecify the name of the file whose existence is to be confirmed.
ostypeSpecify the operating system of the host confirming the existence of the file.
execusername	Specify the name of the user confirming the existence of the file.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpassword	This library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.4 File Making/File Deletion

Class Name

Swrba_File

List of Methods

Method

Description

String make_file(String hostname, String username, String password, String filename, String text, String overwrite, String ostype, String exec_username, String exec_password)

Make text files to the specified host..

"Success" is returned if the file making was successful.

An exception is returned if the file making failed.

String delete_file(String hostname, String username, String password, String filename, String ostype, String exec_username, String exec_password)

Delete files from the specified host.

"Success" is returned if the file deletion was successful.

An exception is returned if the file deletion failed.

Integer return_code()

Return the return value of the file making or deletion results.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host making or deleting the file.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host making or deleting the file.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
filenameSpecify the name of the file to be created or deleted.
textSpecify the text string written to the file to be created.
overwriteSpecify whether to overwrite if the file already exists.
Specify off(do not overwrite) or on(overwrite).
ostypeSpecify the operating system of the host making or deleting the file.
exec_username	Specify the name of the user making or deleting the file.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
exec_password	This library does not use the value of "exec password".
The value of "exec password" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.5 Adding String to Files

Class Name

Swrba_File

List of Methods

Method

Description

String add_string(String hostname, String username, String password, String filename, String addstring, String outputfile, String overwrite, String ostype, String execusername, String execpassword)

Add the text strings to the text file on the specified host. "Success" is returned if the text strings were added to the file successfully.

An exception is returned if text strings failed to be added in the file.

Integer return_code()

Return the return value of the results of adding text strings to the file.

Input Information

hostname       Specify the host name or IP address.
username            Specify the name of the user using SSH to connect to the host containing the file to which the character string needs to be added.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password            Specify the password of the user using SSH to connect to the host containing the file to which the character string needs to be added.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
filename        Specify the name of the file to which the string is to be added.
addstring       Specify the character string that will be added to the file.
outputfile       Specify the name of the file that will output the result of adding the string to the file.
overwrite       Specify whether to overwrite if the "outputfile" already exists.
Specify off(do not overwrite) or on(overwrite).
ostype           Specify the operating system of the host containing the file to which the character string is to be added.
execusername    Specify the name of the user who creates the file.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpassword    This library does not use the value of "execpassword".
The value of "execpassword" will be ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.6 File Copy/File Move

Class Name

Swrba_File

List of Methods

Method

Description

String copy_file(String hostname, String username, String password, String sourcefilename, String destination, String overwrite, String ostype, String execusername, String execpassword)

Copy files on the specified host.

"Success" is returned if the file copy was successful.

An exception is returned if the file copy failed.

String move_file(String hostname, String username, String password, String sourcefilename, String destination, String overwrite, String ostype, String execusername, String execpassword)

Move files on the specified host.

"Success" is returned if the file movement was successful.

An exception is returned if the file movement failed.

Integer return_code()

Return the return value of the file copy or movement results.

Input Information

hostname	Specify the host name or IP address.
usernameSpecify the name of the user using SSH to connect to the host copying or moving the file.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
passwordSpecify the password of the user using SSH to connect to the host copying or moving the file.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
sourcefilenameSpecify the name of the file that is the copy or movement source.
destinationSpecify the name of the file or directory that is the copy or movement destination.
overwriteSpecify whether to overwrite if the file already exists.
ostypeSpecify the operating system of the host copying or moving the file.
execusername	Specify the name of the user copying or moving the file.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name  is ignored even if specified.
execpassword	This library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.7 File Compression/File Decompression

Class Name

Swrba_File

List of Methods

Method

Description

String compress_file(String hostname, String username, String password, String compfilename, String filename, String overwrite, String ostype, String execusername, String execpassword)

Compress files on the specified host.

The compressed format is zip form.

"Success" is returned if the file compression was successful.

An exception is returned if the file compression failed.

String decompress_file(String hostname, String username, String password, String compfilename, String directoryname, String ostype, String execusername, String execpassword)s

Decompress files on the specified host.

The compressed format of a possible decompression is zip form.

"Success" is returned if the file decompression was successful.

An exception is returned if the file decompression failed.

Integer return_code()

Return the return value of the file compression or decompression results.

Input Information

hostnameSpecify the host name or IP address.
usernameSpecify the name of the user using SSH to connect to the host compressing or decompressing the file.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
passwordSpecify the password of the user using SSH to connect to the host compressing or decompressing the file.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
compfilenameSpecify the name of the compressed file.
filenameSpecify the name of the file to be compressed.
directorynameSpecify the name of the decompress destination directory.
overwriteSpecify whether to overwrite if a compressed file already exists.
ostypeSpecify the operating system of the host compressing or decompressing the file.
execusernameSpecify the name of the user compressing or decompressing the file.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpasswordThis library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.8 Character Code Conversion

Class Name

Swrba_File

List of Methods

Method

Description

String change_file_encoding(String searchfile, String outputfile, String character_encoding, String from_encoding, String overwrite)

Convert the character code of the files on the specified host.

"Success" is returned if the character code conversion was successful.

An exception is returned if the character code conversion failed.

Integer return_code()

Return the return value of the result of the character code conversion.

Input Information

searchfile Specify the name of the file whose character code is to be converted.
outputfile Specify the name of the file that that will output the result of the conversion.
from_encoding Specify the character code before conversion.
character_encoding Specify the character code after conversion.
overwrite Specify whether to overwrite if the file that outputs the result already exists.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.9 Searching String in File

Class Name

Swrba_File

List of Methods

Method

Description

String search_file_character_string(String hostname, String username, String password, String searchfile, String searchstring, String outputmode, String searchscope, String searchmode, String exclusionsearch, String outputfile, String overwrite, String ostype, String execusername, String execpassword)

Search for text strings in text files on the specified host.

"Success" is returned if the text string search was successful.

An exception is returned if the text string search failed.

Integer return_code()

Return the return value of the result that the specified text string was searched.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host containing the file whose character string is to be searched.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host containing the file whose character string is to be searched.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
searchfile	Specify the file name containing the character string to be searched.
searchstring	Specify the string to be searched.
outputmode	Specify the format for the search result or output.
Specify line(line number is output), text(content of the line is output), all(line number and content of the line are output).
searchscope	Specify the search range of the character string within the file.
Separate the start position and end position numbers with a hyphen (-).
If the starting position is omitted, the first character of the file becomes the starting position.
If the end position is omitted, the last character of the file becomes the end position.
If the starting position and end position are omitted, the entire file is searched.
(example) If you search the 20th line from the 10th line: 10-20
          If you search the 20th line from the head of the file: -20
          If you search from the 10th line to the end of the file: 10-
searchmode	Specify the search method for the string.
Specify first (search till the first occurrence of the string) or all (search the entire range).
exclusionsearch	Specify whether to use the exclusive search.
Specify off(normal search) or on(exclusive search).
outputfile	Specify the name of the file that will output the search result.
overwrite	Specify whether to overwrite if the "outputfile" already exists.
Specify off(do not overwrite) or on(overwrite).
ostype	Specify the operating system of the host containing the file with the character string to be searched.
execusername	Specify the name of the user searching the character string on the host where the file exists.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpassword	This library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb

3.15.6.10 Replacing String in File

Class Name

Swrba_File

List of Methods

Method

Description

String replace_file_character_string(String hostname, String username, String password, String searchfile, String searchstring,String replacestring String outputfile, String overwrite, String ostype, String execusername, String execpassword)

Replace text strings in text files on the specified host.

"Success" is returned if the text string replacement was successful.

An exception is returned if the text string replacement failed.

Integer return_code()

Return the return value of the result that the specified text string was searched.

Input Information

hostname	Specify the host name or IP address.
username	Specify the name of the user using SSH to connect to the host containing the file to replace the character string.
If the operation component connects with the file transfer infrastructure, the connected user name will be fixed at either of the following names and cannot be changed. In this case, the user name is ignored even if specified.
- If the Business Server is running on Windows: Administrator
- If the Business Server is running on Linux: root
password	Specify the password of the user using SSH to connect to the host containing the file whose character string is to be replaced.
If the operation component connects with the file transfer infrastructure, the password is ignored even if specified.
searchfile	Specify the file name containing the character string to be replaced.
searchstring	Specify the string to be replaced.
replacestring	Specify the string after replacement.
outputfile	Specify the name of the file that will output the result of the character string replacement.
overwrite	Specify whether to overwrite if the "outputfile" already exists.
Specify off(do not overwrite), on(overwrite).
ostype	Specify the operating system of the host containing the file whose character string is to be replaced.
execusername	Specify the name of the user replacing the character string on the host where the file exists.
If the host specified by the "hostname" option is running on Windows and the connection is made using the file transfer infrastructure, execute the command as an administrator. In this case, the user name is ignored even if specified.
execpassword	This library does not use the value of "execpassword".
The value of "execpassword" is ignored even if specified.

Notes

File Location

Windows

<Installation directory>\SWRBAM\rbaope\bin\parts\lib\

standard\swrba_file.rb

Linux

/opt/FJSVswrbam/rbaope/bin/parts/lib/standard/swrba_file.rb