-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanonize2.cpp
More file actions
29 lines (27 loc) · 1.01 KB
/
canonize2.cpp
File metadata and controls
29 lines (27 loc) · 1.01 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
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <sys/stat.h>
int main(int argc, char *argv[]) {
if (argc < 2) { std::cout << "No Arguments Detected \n"; return -3; }
if (argc == 2 && argv[1] == "INPUTcin") {
// ;
}
else if (argc >= 3) {
std::string ln = "/usr/local/bin/";
ln+=argv[1];
std::ofstream file(ln.c_str());
file << "#!/bin/sh\n";
for (short i = 2; i<argc; i++) {
file << argv[i];
file << " ";
}
file << "\"$@\"";
file.close();
chmod(("/usr/local/bin/" + (std::string) argv[1]).c_str(), 0755);
// std::string cmdline = (std::string) "sudo chmod +x /usr/local/bin/" + (std::string) argv[1];
// const char *cmd = (const char*) cmdline.c_str();
// std::system(cmd);
}
return 0;
}