Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
* Release the client's profile handle. */<br />
QSYRLSPH(client_ph, NULL);<br />
if (error.Bytes_Available != 0) {<br />
LogError(“Could not release client's profile handle, ”<br />
“QSYRLSPH() failed with exception %7.7s\n”,<br />
error.Exception_Id);<br />
break;<br />
}<br />
close(cfd);<br />
continue;<br />
}<br />
/* Build the file descriptor map for the child. */<br />
fd_count = 3;<br />
fd_map[0] = cfd;<br />
fd_map[1] = cfd;<br />
fd_map[2] = cfd;<br />
/* Build the argv array for the child. */<br />
args[0] = <strong>qsh</strong>_pgm;<br />
args[1] = “-login”; /* Do login processing */<br />
args[2] = “-s”; /* Take input from stdin */<br />
args[3] = “-i”; /* Run as an interactive shell */<br />
args[4] = NULL;<br />
/* Build the environ array for the child. */<br />
sprintf(home_var, “HOME=%s”, cpw->pw_dir);<br />
sprintf(logname_var, “LOGNAME=%s”, cpw->pw_name);<br />
envs[0] = home_var;<br />
envs[1] = logname_var;<br />
envs[2] = path_var;<br />
envs[3] = stdio_var;<br />
envs[4] = terminal_type_var;<br />
envs[5] = nlspath_var;<br />
envs[6] = NULL;<br />
/* Set up the inheritance structure. */<br />
memset(&inherit, '\0', sizeof(struct inheritance));<br />
inherit.flags = SPAWN_SETTHREAD_NP;<br />
inherit.pgroup = SPAWN_NEWPGROUP;<br />
/* Change to the home directory for the client. The child process<br />
inherits this as its current working directory. */<br />
chdir(cpw->pw_dir);<br />
/* Start a child process running the shell interpreter. */<br />
if (spawn(args[0], fd_count, fd_map, &inherit, args, envs) < 0) {<br />
LogError(“Could not start <strong>qsh</strong> process, spawn() failed with ”<br />
“errno=%d\n”, errno);<br />
SendError(cfd, “Could not start <strong>qsh</strong> process\n”);<br />
}<br />
/* Clean up for the next connection. */<br />
chdir(server_dir);<br />
close(cfd);<br />
/* Switch back to server's user profile. */<br />
QWTSETP(server_ph, &error);<br />
if (error.Bytes_Available != 0) {<br />
LogError(“Could not switch back to server's profile, ”<br />
“QWTSETP() failed with exception %7.7s\n”,<br />
error.Exception_Id);<br />
break;<br />
}<br />
/* Release the client's profile handle. */<br />
QSYRLSPH(client_ph, &error);<br />
if (error.Bytes_Available != 0) {<br />
LogError(“Could not release client's profile handle, ”<br />
“QSYRLSPH() failed with exception %7.7s\n”,<br />
error.Exception_Id);<br />
break;<br />
}<br />
} /* End of while */<br />
/* Clean up. */<br />
close(sfd);<br />
Chapter 6. Remote client examples 123