29.06.2013 Views

Qshell Interpreter (qsh) - FTP Directory Listing - IBM

Qshell Interpreter (qsh) - FTP Directory Listing - IBM

Qshell Interpreter (qsh) - FTP Directory Listing - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6. Remote client examples<br />

Server program<br />

The following two example programs show how to use a remote client that connects<br />

to an interactive <strong>qsh</strong> session on a AS/400.<br />

v Server program<br />

v Client program<br />

The server program is compiled and run on a AS/400.<br />

v See Creating and running the server program for more information.<br />

The client program is compiled and run on a remote system.<br />

v See Creating and running the client program for more information.<br />

[ Legal | AS/400 Glossary ]<br />

Disclaimer<br />

<strong>IBM</strong> grants you a nonexclusive license to use this as an example from which you can<br />

generate similar function tailored to your own specific needs.<br />

This sample code is provided by <strong>IBM</strong> for illustrative purposes only. These examples have not<br />

been thoroughly tested under all conditions. <strong>IBM</strong>, therefore, cannot guarantee or imply<br />

reliability, serviceability, or function of these programs.<br />

All programs contained herein are provided to you “AS IS” without any warranties of any<br />

kind. The implied warranties of merchantability and fitness for a particular purpose are<br />

expressly disclaimed.<br />

/**********************************************************************/<br />

/* */<br />

/* Name: server.c */<br />

/* */<br />

/* Description: This program is a server for starting interactive */<br />

/* <strong>qsh</strong> sessions on remote clients. The program */<br />

/* listens for connections from clients. When a */<br />

/* connection is accepted, it reads the user name */<br />

/* and password of the client. It then swaps to the */<br />

/* the specified user profile and spawns a new */<br />

/* process running the <strong>qsh</strong> shell interpreter that */<br />

/* handles the connection. */<br />

/* */<br />

/* Parameters: 1. Port number to listen for connections on. */<br />

/* */<br />

/* Notes: 1. The user name and password are sent as plain text */<br />

/* from the client. */<br />

/* 2. The user profile running this program must have */<br />

/* authority to the QSYGETPH, QSYRLSPH, and */<br />

/* QWTSETP APIs. */<br />

/* 3. You will need to change the value of the NLSPATH */<br />

/* environment variable if your system is using a */<br />

/* different language than 2924. */<br />

/* */<br />

/**********************************************************************/<br />

/**********************************************************************/<br />

/* Includes */<br />

/**********************************************************************/<br />

#include /* fopen(), vfprintf() */<br />

#include /* socket(), bind(), etc. */<br />

#include /* sockaddr_in, INADDR_ANY, etc. */<br />

#include /* inet_ntoa() */<br />

© Copyright <strong>IBM</strong> Corp. 1998, 1999 119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!