-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshConnectionCode
82 lines (71 loc) · 2.29 KB
/
sshConnectionCode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
QStringList myTables;
myTables= db.tables(QSql::Tables);
QString l = "";
for (int i = 0; i < myTables.size(); i++)
l.append(myTables.at(i).toLocal8Bit().constData());
QMessageBox::information(this, "Tables", l);
QSqlQuery query;
query.exec("SHOW Tables");
QString tableName = "";
while (query.next()) {
tableName.append(query.value(0).toString());
}
QMessageBox::information(this, "Tables", tableName);
// program = "/bin/bash";
// args << "../../../../ssh_connect";
QProcess *SSH = new QProcess();
QString SSH_program;
QStringList SSH_args;
SSH_program = "ssh";
SSH_args << "-T" << "-i" << "../../../../.ssh/qtc_id" << "trombetta@blue.cs.sonoma.edu";
SSH->start(SSH_program, SSH_args);
SSH->waitForFinished();
QString SSH_output(SSH->readAllStandardOutput());
qDebug() << SSH_output;
SSH_output = SSH->readAllStandardError();
qDebug() << SSH_output;
QProcess *mysql = new QProcess(SSH);
QString mysql_program;
mysql_program = "mysql";
QStringList mysql_args;
mysql_args << "-u" << "ktrombet_cs355fl20" << "-p";
mysql->setProcessChannelMode(QProcess::ForwardedChannels);
mysql->start(mysql_program, mysql_args);
mysql->waitForFinished();
QByteArray mysql_output(mysql->readAllStandardOutput());
qDebug() << mysql_output;
mysql_output = mysql->readAllStandardError();
qDebug() << mysql_output;
mysql->write("tr7615654\n");
mysql->waitForFinished();
mysql_output = mysql->readAllStandardOutput();
qDebug() << mysql_output;
mysql_output = mysql->readAllStandardError();
qDebug() << mysql_output;
mysql->write("SHOW Databases;\n");
mysql->waitForFinished();
mysql_output = mysql->readAllStandardOutput();
qDebug() << mysql_output;
mysql_output = mysql->readAllStandardError();
qDebug() << mysql_output;
QProcess *process2 = new QProcess();
process2->setProcessChannelMode(QProcess::MergedChannels);
process2->start("cmd", QStringList() << "ls");
// Get the output
QString output2;
if (process2->waitForStarted(-1)) {
while(process2->waitForReadyRead(-1)) {
output2 += process2->readAll();
}
}
process2->waitForFinished();
process->write("ls");
output = process->readAllStandardOutput();
qDebug() << output;
// QDir dir;
//qDebug() << dir.absolutePath();
QStringList args2;
args2 << "trombetta@blue.cs.sonoma.edu";
QProcess::startDetached("ssh", args2);
*/