Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function CheckIfDirectoryIsNotEmpty() {
- let value;
- let Client = require('ssh2-sftp-client');
- let sftp = new Client();
- sftp.connect({
- host: 'xxxxx',
- port: 'xx',
- username: 'xxxxxxxx',
- password: 'xxxxxxxx'
- }).then(() => {
- return sftp.list('/opt/cm-shared-data/example/')
- }).then((data) => {
- if(data.length == 0){
- value = 0;
- }
- else { value = 1;}
- sftp.end();
- return value;
- });
- }
- async function start() {
- var a = CheckIfDirectoryIsNotEmpty();
- console.log(a); // "undefined"
Add Comment
Please, Sign In to add comment