-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
79 lines (65 loc) · 1.35 KB
/
main.cpp
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
#include <iostream>
#include <fstream>
#include <ctime>
#include <thread>
#include <chrono>
using namespace std;
void weather();
void download();
void post();
string arr[5];
int main()
{
download();
weather();
post();
while(0==0)
{
for (int i=3600; i>0; --i) {
//hour timer
std::this_thread::sleep_for (std::chrono::seconds(1));
}
download();
weather();
post();
}
return 0;
}
void download()
{
system("curl https://HOSTNAME/jpg/image.jpg -o /root/AxisPictureToTwitter/images/photo.jpg"); //YOU MAY HAVE TO CHANGE THE IMAGES FOLDER LOCATION. LEAVE photo.jpg AT THE END BUT PWD IN /images DIR
}
void weather()
{
system("weather -q ##### --imperial > weather.txt"); //ADD LOCAL ZIP CODE WHERE ##### IS
string line;
ifstream myfile ("weather.txt");
if (myfile.is_open())
{
int i = 0;
while ( getline (myfile,line) )
{
arr[i] = line;
//cout << arr[i] << endl;
i++;
}
myfile.close();
}
system("touch weather.js");
ofstream out ("weather.js");
out << "var weather = [" << endl;
out << "'";
out << arr[0] << ". ";
out << arr[1] << ". ";
out << arr[2] << ". ";
out << arr[3] << ". ";
out << arr[4] << ". ";
out << "'" << endl;
out << "];" << endl;
out << "module.exports = weather;" << endl;
out.close();
}
void post()
{
system("node server.js");
}