remote_file_send()
Send an ASCII file to a remote PATROL Agent.
Syntax
[class],sendID,[access])
Parameter
Parameter | Definition |
---|---|
sessionID | identifier of the remote PATROL Agent session to which the file is sent The sessionID is returned by the remote_open() function when you open a remote PATROL Agent session. |
srcfilename | full path name of the ASCII file that is to be sent to the remote PATROL Agent. |
destfilename | name to be given the ASCII file on the remote PATROL Agent host The file is written to the path: |
catalog | name of the catalog to which the event generated by the file transfer belongs *Valid Values* |
class | name of the class to which the event generated by the file transfer belongs *Valid Values* |
sendID | user-defined identifier for the file send operation |
access | integer designating the access mode assigned to the destination file In Unix, file access is defined using an octal representation of the binary rwxrwxrwx (read, write, execute) permissions for owner, group, and world. The access parameter is the decimal equivalent of the octal value used in Unix. To define theaccess parameter, determine the octal value for the file permissions and convert it to a decimal value. Valid Values Default |
Description
The remote_file_send() function copies srcfilename from the host on which the function executes to destfilename on the PATROL Agent host identified by sessionID . The remote_file_send() function returns 1 if you called this function with valid parameters. Otherwise the function returns 0. There is no built-in limit to the size of the file that can be transferred.
If the PATROL_REMOTE environment variable is defined for the remote host, the file is written to $PATROL_REMOTE. If the PATROL_REMOTE environment variable is not defined, the file gets written to $PATROL_HOME/remote on the remote PATROL Agent.
The remote_file_send() function generates an event on the PATROL Agent host identified by sessionID for the file send operation using the catalog and class parameters. If the catalog and class parameters are omitted, the remote_file_send() function creates the STANDARD catalog event RemProcess.
For more information on using the remote functions, see remote_open().
DeterminingtheDecimalvaluefor_access_"> Determining the Decimal value for access
The access parameter is the decimal equivalent of the octal representation of the binary rwxrwxrwx (read, write, execute) permissions for owner, group, and world used under Unix.
The simplest way to determine the decimal equivalent is to determine the octal value for Unix and convert it to a decimal value.
Octal Permissions in Unix
In Unix, the valid range for the file permissions is 000-777 where the first digit is the owner permission, the second digit is the group permission, and the third digit is the world permission.
The permissions are assigned to octal values as follows:
0 = no access (---)
1 = execute(--x)
2 = write(-w-)
3 = write and execute(-wx)
4 = read(r--)
5 = read and execute(r-x)
6 = read and write(rw-)
7 = read, write, and execute (rwx)
For Example, 666 is the octal value that would set the Unix file permissions to rw-rw-rw- which is read and write permission to the file for owner, group, and world.
Decimal Permissions
The octal values for permissions are easy to determine. To determine the access parameter for the remote_file_send() function, start with the octal value and convert it to a decimal value. For information on using the PSL convert_base()function to convert octal to decimal, see convert_base().
The following table compares the decimal and octal values for common file permissions.
Decimal and Octal File Permissions
Octal | Decimal | Permissions (Owner, Group, World) |
---|---|---|
444 | 292 | r--r--r-- |
664 | 436 | rw-rw-r-- |
666 | 438 | rw-rw-rw- |
744 | 484 | rwxr--r-- |
770 | 504 | rwxrwx--- |
777 | 511 | rwxrwxrwx |
For more information on Unix file permissions, see the chmod(1) user command in the Unix documentation.
Example
The following is an example of the remote_file_send() function where the access parameter is set as an octal value of 744 (read, write, and execute access for the owner and read access for the group and world-rwxr--r-- ) and then converted to a decimal value using the convert_base() function:
octal_access=”744”;
# convert the octal permission to a decimal for the remote_file _send()
decimal_access=convert_base(octal_access,8,10);
remote_file_send(
mysession, # session handle returned by the remote_open() function
"/tmp/myfile", # name of file to send
"myremotefile", # name of file on remote PATROL Agent host
"", # STANDARD catalog for file send event
"", # RemProcess class for file send event
"myfileID", # myFileID identifies this file send operation
decimal_access # file access permission of rwxr--r--
);