[ Previous | Next | Contents | Search ]
3270 Host Connection Program 2.1 and 1.3.3 for AIX: Guide and Reference

Creating HCON File Transfer Shell Procedures

The following sections describe the procedures for creating and using an HCON file transfer shell procedure.

Prerequisite

To run the file transfer shell procedure, you must be registered as an HCON user. To register, use the smit hcon fast path or mkhconu command.

Shell Procedure

An HCON file transfer can be invoked in a shell procedure by entering the user interface commands into a file and running the procedure. The procedure can inspect the return code from the fxfer command by testing the $? environment variable after the command runs. A return code of 1 indicates that an error has occurred, and a return code of 0 indicates that the transfer has completed.

The following example shell procedure accepts the name of the local system file as the first command line parameter (the $1 procedure variable) and the name of the host file as the second parameter (the $2 procedure variable). The shell procedure instructs the fxfer command to:

The shell procedure checks the error code environment variable (the $? variable) to see if the transfer is successful and echoes this information to the user.

Notes:
  1. When running the shell procedure, include the appropriate quotation marks when entering the host file name.
  2. The file transfer process prompts the user for the host password.

Shell Procedure Example

Following is the fx sample shell procedure:

## fx shell procedure  ##
# This procedure accepts two command line parameters:
#   $1 - local file name
#   $2 - host file name
#
# This procedure uploads the local file to the host specified
# in HCON session profile a, and translates the file from
# ASCII to EBCDIC.
#
# If necessary, the procedure logs into the host automatically.
# Status messages are placed in the $HOME/transfer.stat file.
# After the procedure runs, the file transfer prompts for
# the host password.
#
fxfer -n a -utf $HOME/transfer.stat -x matthew,vm6 "$1" "$2"
if test $? != 0
then
  echo "File transfer return value indicates an error."
  echo "See the $HOME/transfer.stat file for information."
else
  echo "File transfer completed successfully."
fi

Using the File Transfer Shell Procedure

To use the fx shell procedure to transfer the local file /home/matthew/newinfo to the host file newinfo on an MVS/TSO host, enter:

fx /home/matthew/newinfo "newinfo"

The procedure invokes the fxfer command to transfer the file to the host computer and prompts for the host password.

To use the shell procedure for a transfer to a VM/CMS host, enter:

fx /home/matthew/newinfo "newinfo file a"

In each case, the host type must be specified in the session profile.

Bypassing the Password Prompt

Redirecting Input into the File Transfer

To bypass password entry when prompted for the password, redirect input into the file transfer. For example, if user matthew 's host password is u1matt , change the file transfer code in the procedure as follows:

fxfer -n a -utf $HOME/transfer.stat -x matthew,vm6 "$1" "$2" << END
u1matt
END

Using this redirection allows the procedure to bypass prompting the user for the password. Instead, the file transfer process uses the password u1matt .

Using echo Command

Use the echo command to give the password to the shell procedure, as follows:

echo "u1matt" | fx /home/matthew/infofile "infofile"
Using the cat Command

Place the host password in a file and use the cat command to give the password to the shell procedure. For example, if the password is in the file /home/matthew/logfile , enter the following to start the file transfer:

cat /home/matthew/logfile | fx /home/matthew/newinfo "newinfo"
Note: When using these techniques to avoid a password prompt, you may also want to specify a status file using the -f flag of the fxfer command. Otherwise, all of the file transfer status messages are put in the $HOME/hconerrors file.

Using the Same Shell Procedure with Different Host Logon IDs

Using a separate file for the host password also allows you to change the logon ID for the host. For example, change the file transfer code in the procedure as follows:

fxfer -n a -utf $HOME/transfer.stat "$1" "$2"

Then include both the host logon ID and the host password in a separate file and use the cat command to give the information to the file transfer procedure. For example, if the /home/matthew/.hostinfo file contains the following lines:

matt,vm6
mattpass

the command

cat /home/matthew/.hostinfo | fx /home/matthew/upfile "newfile"

causes the fx shell procedure to invoke the fxfer command and log on to the specified host using the logon ID string matt,vm6 and the host password mattpass .


[ Previous | Next | Contents | Search ]