Skip to content

Commit 5144fc2

Browse files
first commit
0 parents  commit 5144fc2

File tree

4 files changed

+235
-0
lines changed

4 files changed

+235
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+

index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//const url = "ftp://ftp.uconn.edu/48_hour/";
2+
const url = "ftp://pubftp.spp.org/Markets/DA/BINDING_CONSTRAINTS/2018/05/By_Day/";
3+
const { spawn } = require("child_process");
4+
const folders = [];
5+
const ls = spawn('curl', [url]);
6+
7+
ls.stdout.on('data', (data) => {
8+
folders.push(...data.toString().split('\n'));
9+
});
10+
11+
12+
ls.on('close', data => {
13+
14+
// console.log('done', folders);
15+
for (let i = 0; i < folders.length; i++) {
16+
let temp = folders[i].split(' ');
17+
// console.log(temp);
18+
if (temp[temp.length - 1].split('.')[1] == 'csv') {
19+
const fUrl = `${url}${temp[temp.length - 1]}`;
20+
console.log(fUrl);
21+
const download = spawn('curl', [fUrl, '--output', '/home/andy/Desktop/Code/snippet/random/js/ftpfiles/data' + temp[temp.length - 1]]);
22+
download.on('close', data => console.log("File Download -> ", temp[temp.length -1]));
23+
}
24+
}
25+
})
26+

package-lock.json

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ftpfiles",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Andythedandyone",
10+
"license": "ISC",
11+
"dependencies": {
12+
"node-wget": "^0.4.2",
13+
"wget-improved": "^1.5.0"
14+
}
15+
}

0 commit comments

Comments
 (0)