Skip to content

Commit 1f09f28

Browse files
committed
Updated index.js
1 parent 0b0b595 commit 1f09f28

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

index.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@ try {
55

66
/* SSH input commands */
77
const commands = core.getInput('commands');
8-
if(commands){
9-
console.log(commands)
10-
let items = commands.split("\n");
11-
console.log(items)
12-
} else {
13-
const host = {
14-
server: {
15-
host: core.getInput('host'),
16-
userName: core.getInput('username'),
17-
password: core.getInput('password')
18-
},
19-
commands: [ssh_1, ssh_2, ssh_3, ssh_4]
20-
}
21-
/* creating new SSH client */
22-
const SSH = new SSH2Shell(host);
23-
24-
/* Connecting... */
25-
SSH.connect(function(sessionText){
26-
/* Response text */
27-
console.log(sessionText);
28-
console.log("Successfully executed ssh commands!");
29-
});
8+
9+
/* Splitting commands if there are multiple */
10+
let items = commands.split("\n");
11+
12+
const host = {
13+
server: {
14+
host: core.getInput('host'),
15+
userName: core.getInput('username'),
16+
password: core.getInput('password')
17+
},
18+
commands: [items],
3019
}
20+
21+
/* creating new SSH client */
22+
const SSH = new SSH2Shell(host);
23+
24+
/* Connecting... */
25+
SSH.connect(function(sessionText){
26+
/* Response text */
27+
console.log(sessionText);
28+
if(sessionText == 'Ready'){
29+
console.log("Successfully executed ssh commands!");
30+
}
31+
});
32+
3133
} catch (error) {
3234
core.setFailed(error.message);
3335
}

0 commit comments

Comments
 (0)