[self setStatus:@"Bad username/password" isError:YES];
goto shutdown;
}
-
+ /*
stat([[dragRegion filePath] UTF8String], &fileInfo);
LIBSSH2_CHANNEL *channel = libssh2_scp_send(ssh, "~/tempupload.pdf", 0755, (unsigned long)fileInfo.st_size);
libssh2_channel_wait_closed(channel);
libssh2_channel_free(channel);
channel = NULL;
+ */
+
+ LIBSSH2_CHANNEL *channel = libssh2_channel_open_session(ssh);
+ if (!channel)
+ {
+ [self setStatus:@"Could not open SSH channel for printing" isError:YES];
+ goto shutdown;
+ }
+
+ if (libssh2_channel_request_pty(channel, "vanilla"))
+ {
+ [self setStatus:@"Could not open ANSI TTY" isError:YES];
+ goto shutdown;
+ }
+
+ if (libssh2_channel_shell(channel))
+ {
+ [self setStatus:@"Failed to open remote shell" isError:YES];
+ goto shutdown;
+ }
+
+ [self setStatus:@"Opened remote SSH shell" isError:NO];
+
+ libssh2_channel_flush_ex(channel, LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL);
+
+ /*
+ char *e = malloc(1024 * sizeof(char));
+ libssh2_session_last_error(ssh, &e, NULL, 0);
+ NSLog(@"e = %s", e);
+ */
+
+ libssh2_channel_set_blocking(channel, 0);
+
+ char b[1024];
+ int r;
+ do
+ {
+ memset(&b, '\0', sizeof(b));
+ sleep(1);
+ r = libssh2_channel_read(channel, b, sizeof(b));
+ NSLog(@"b(%i) = %s", r, b);
+ } while (r > 0);
+
+ char *cmd = "touch /u17/ugrad/rsesek/temp.foo\r\n\0";
+ NSLog(@"numbytes = %i", libssh2_channel_write(channel, cmd, sizeof(char) * strlen(cmd)));
+
+ do
+ {
+ memset(&b, '\0', sizeof(b));
+ sleep(1);
+ r = libssh2_channel_read(channel, b, sizeof(b));
+ NSLog(@"b(%i) = %s", r, b);
+ } while (r > 0);
+
+ [self setStatus:@"Printed!" isError:NO];
+
+ libssh2_channel_send_eof(channel);
+ libssh2_channel_eof(channel);
+ libssh2_channel_close(channel);
shutdown:
+ if (channel)
+ {
+ libssh2_channel_free(channel);
+ channel = NULL;
+ }
libssh2_session_disconnect(ssh, "Normal disconnect.");
libssh2_session_free(ssh);