Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
130 <strong>Qshell</strong> <strong>Interpreter</strong> (<strong>qsh</strong>)<br />
}<br />
/* Get the user name and password from the x/.netrc file. */<br />
else {<br />
if (GetPassword(hostname, ascii_user, ascii_pwd) != 0) {<br />
fprintf(stderr, “<strong>qsh</strong>c: Could not find user or password in x/.netrc\n”);<br />
exit(1);<br />
}<br />
}<br />
/* Convert the user name and password to EBCDIC. */<br />
if (ConvertToEBCDIC(ascii_user, strlen(ascii_user)+1, ebcdic_user, 11) < 0) {<br />
fprintf(stderr, “<strong>qsh</strong>c: Could not convert user %s to EBCDIC\n”, ascii_user);<br />
exit(1);<br />
}<br />
if (ConvertToEBCDIC(ascii_pwd, strlen(ascii_pwd)+1, ebcdic_pwd, 11) < 0) {<br />
fprintf(stderr, “<strong>qsh</strong>c: Could not convert password %s to EBCDIC\n”,<br />
ascii_pwd);<br />
exit(1);<br />
}<br />
/* Send the user name and password to the <strong>qsh</strong> server. Note that the<br />
user name and password are sent as plain text. */<br />
if ((rc = write(sd, (void *)ebcdic_user, strlen(ebcdic_user)+1)) < 0) {<br />
perror(“<strong>qsh</strong>c: write() failed sending username\n”);<br />
close(sd);<br />
exit(1);<br />
}<br />
if ((rc = write(sd, (void *)ebcdic_pwd, strlen(ebcdic_pwd)+1)) < 0) {<br />
perror(“<strong>qsh</strong>c: write() failed sending password\n”);<br />
close(sd);<br />
exit(1);<br />
}<br />
printf(“Started <strong>qsh</strong> session on %s\n\n”, sysname);<br />
/********************************************************************/<br />
/* Process input and output between the user and the remote shell. */<br />
/********************************************************************/<br />
/* Loop forever. */<br />
while (1) {<br />
/* Select on stdin and the socket connected to the remote shell. */<br />
FD_ZERO(&read_set);<br />
FD_SET(0, &read_set);<br />
FD_SET(sd, &read_set);<br />
rc = select(sd+1, &read_set, NULL, NULL, NULL);<br />
if ((rc < 0) && (errno != EINTR)) {<br />
perror(“<strong>qsh</strong>c: select() failed”);<br />
exit(1);<br />
}<br />
if (rc == 0) {<br />
continue;<br />
}<br />
/* Process data entered by the terminal user. */<br />
if (FD_ISSET(0, &read_set)) {<br />
/* Read the data from the terminal. */<br />
gets(ascii_buf);<br />
/* Convert the string to EBCDIC. */<br />
len = strlen(ascii_buf);<br />
if (ConvertToEBCDIC(ascii_buf, len, ebcdic_buf, DEFAULT_BUF) < 0) {<br />
fprintf(stderr, “<strong>qsh</strong>c: Could not convert input string to EBCDIC\n”);<br />
continue;<br />
}<br />
/* Put a newline on the end of the string. */<br />
*(ebcdic_buf+len) = 0x25;<br />
/* Send the data to the remote shell. */<br />
if (write(sd, ebcdic_buf, len+1) < 0) {<br />
perror(“<strong>qsh</strong>c: write() failed sending input”);<br />
}<br />
}<br />
/* Process data from the remote shell. */<br />
if (FD_ISSET(sd, &read_set)) {