#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <getopt.h>
#include <unistd.h>
using namespace std;
void usage(char* argv)
{
cout << "usuario: " << argv << " -w /root/Desktop/123.bat -i 192.168.0.1 -p 666 -s C:\\users\\...."
<< endl;
cout << endl << " -s direccion de carpeta de salida para windows" << endl;
cout << " -w direccion a crear batch" << endl;
cout << " -i direccion ip" << endl << " -p puerto" << endl;
cout << " -h Mostrar ayuda" << endl;
}
int main(int argc, char** argv)
{
if(argc <= 1)
{
usage(argv[0]);
return -1;
}
int opt, optchar;
unsigned short int puerto;
char* ip;
string dirout, dirin, dirIp;
while(optchar = getopt(argc, argv, "wspi:h:") != EOF)
{
switch(optchar)
{
case 'w':
{
dirout = optarg;
break;
}
case 's':
{
dirin = optarg;
break;
}
case 'i':
{
ip = optarg;
break;
}
case 'p':
{
puerto = atoi(optarg);
break;
}
case '?':
case 'h':
{
usage(argv[0]);
return -1;
}
}
}
string nomCarp = "";
ofstream archivo(dirout.c_str(), ios_base::app);
string batch = "@echo off"+ '\n';
batch = batch +"if exist C:\\users\\%username%\\AppData\\Roaming\\" + nomCarp + "(goto :crearConexion)";
batch = batch + "else (goto :crearCarpeta)\n";
batch = batch + ":crearCarpeta" + '\n';
batch = batch + "mkdir" + " "+ '\n';
batch = batch + "move:";
//archivo << batch;
return 0;
}
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <getopt.h>
#include <unistd.h>
using namespace std;
void usage(char* argv)
{
cout << "usuario: " << argv << " -w /root/Desktop/123.bat -i 192.168.0.1 -p 666 -s C:\\users\\...."
<< endl;
cout << endl << " -s direccion de carpeta de salida para windows" << endl;
cout << " -w direccion a crear batch" << endl;
cout << " -i direccion ip" << endl << " -p puerto" << endl;
cout << " -h Mostrar ayuda" << endl;
}
int main(int argc, char** argv)
{
if(argc <= 1)
{
usage(argv[0]);
return -1;
}
int opt, optchar;
unsigned short int puerto;
char* ip;
string dirout, dirin, dirIp;
while(optchar = getopt(argc, argv, "wspi:h:") != EOF)
{
switch(optchar)
{
case 'w':
{
dirout = optarg;
break;
}
case 's':
{
dirin = optarg;
break;
}
case 'i':
{
ip = optarg;
break;
}
case 'p':
{
puerto = atoi(optarg);
break;
}
case '?':
case 'h':
{
usage(argv[0]);
return -1;
}
}
}
string nomCarp = "";
ofstream archivo(dirout.c_str(), ios_base::app);
string batch = "@echo off"+ '\n';
batch = batch +"if exist C:\\users\\%username%\\AppData\\Roaming\\" + nomCarp + "(goto :crearConexion)";
batch = batch + "else (goto :crearCarpeta)\n";
batch = batch + ":crearCarpeta" + '\n';
batch = batch + "mkdir" + " "+ '\n';
batch = batch + "move:";
//archivo << batch;
return 0;
}