-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh2.js
More file actions
40 lines (31 loc) · 1.24 KB
/
ssh2.js
File metadata and controls
40 lines (31 loc) · 1.24 KB
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
// ssh manager prototype
const Table = require('easy-table');
const input = require('input');
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const shell = require('shelljs');
const { spawn } = require('child_process');
const scriptPath = './ssh2.sh'; // Replace with the actual path to your script
//adjust script permissions
const scriptPermissions = '755'; // Set the desired permissions (e.g., '755' for rwxr-xr-x)
const scriptPathAbsolute = path.resolve(scriptPath);
fs.chmod(scriptPathAbsolute, scriptPermissions, (err) => {
if (err) {
console.error(`Error setting permissions: ${err}`);
} else {
console.log(`Permissions set to ${scriptPermissions} for ${scriptPath}`);
}
});
const child = spawn(scriptPath, [], { stdio: 'inherit', });
child.on('close', (code) => {
console.log(`Bash script finished with code ${code}`);
// You can perform actions after the script finishes here
});
child.on('error', (err) => {
console.error(`Failed to start script: ${err}`);
});
//input.text('Enter the SSH command: ', { default: 'ssh samuel@samuelm.us.to' }).then(commandToRun => {
// console.log(`You entered: ${commandToRun}`);
//});