#include <iostream>
#include <string>
using namespace std;
int main()
{
string username = "pgpool";
string ip = "192.168.1.48";
int port = 9898;
int node = 1;
string command = "pcp_recovery_node -h "+ip+" -p "+to_string(port)+" -U "+username+" -n "+to_string(node);
cout << command << endl;
system(command.c_str());
return 0;
}
onsole
#!/bin/bash
#pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
n=$( pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 )
echo $n
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int i=0;
while(i<4)
{
cout << "ping" << endl;
i++;
}
}
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#include "libpq/pqformat.h" /* needed for send/recv functions */
#include "utils/guc.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
PG_FUNCTION_INFO_V1(pcp_recovery_node);
Datum
pcp_recovery_node(PG_FUNCTION_ARGS)
{
int32 id = PG_GETARG_INT32(0);
int rc;
int ret;
char *node_info = NULL;
char *pcp_recovery_node_path = "/usr/local/bin/pcp_recovery_node";
char *pcp_recovery_node_args = "-h 192.168.1.48 -p 9898 -U pgpool -n";
char pcp_recovery_node_com[100] =
#include <iostream>
#include <string>
using namespace std;
int main()
{
string pass;
cin >> pass;
string command = "echo " + pass + " | pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1";
cout << command;
system(command.c_str());
}
#include <stdio.h>
int main()
{
char command[100];
sprintf(command, "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1");
system(command);
return 0;
}
#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
int main() {
cout << "Hola Rodrigo!" << endl;
string url = "http://www.google.com";
CURL* curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
CURLcode res = curl_easy_perform(curl);
if (res == CURLE_OK) {
cout << "Ping funciona!" << endl;
} else {
cout << "Ping no funciona!" << endl;
}
}
cout << "Saliendo del programa..." << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = "";
cout << "Password: ";
getline(cin, s);
cout << "You entered: " << s << endl;
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
using namespace std;
int main()
{
/* initialize random seed: */
srand (time(NULL));
int numero = rand() % 100;
string command = "ping -c 1 -t 1 ";
string ip = "8.8.8.8";
string outputSt = "> /home/pi/out.txt";
string num = std::to_string(numero);
string final = command + ip + outputSt;
cout << final << endl;
system(final.c_str());
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
int main(){
int fd;
char * myfifo = "/tmp/myfifo";
mkfifo(myfifo, 0666);
char arr1[80], arr2[80];
while(1){
fd = open(myfifo, O_WRONLY);
fgets(arr2, 80, stdin);
write(fd, arr2, strlen(arr2)+1);
close(fd);
fd = open(myfifo, O_RDONLY);
read(fd, arr1, sizeof(arr1));
printf("User2: %s\n", arr1);
close(fd);
}
return 0;
}
#
private string Execute(string user, string password, string hostname, string command)
{
var result = string.Empty;
var info = new ProcessStartInfo("ssh", user + "@" + hostname + " " + command)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
ErrorDialog = false
};
using (var proc = Process.Start(info))
{
if (proc != null)
{
proc.ErrorDataReceived += (sender, e) => Console.WriteLine(e.Data);
proc.OutputDataReceived += (sender, e) => Console.WriteLine(e.Data);
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();
}
}
return result;
}
int ping(string person) {
if(ping(person)) {
return 'hola ' + person;
}
else {
return 'no puedo localizar a ' + person
}
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 -w 'contraseña'
void setServerAddr(struct sockaddr_in serv_addr, char *ip, int port) {
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
inet_pton(AF_INET, ip, &serv_addr.sin_addr);
}
sudo -u postgres pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -w password -n 1
int main(int argc, char *argv[])
{
char *host;
int port;
char *username;
int nodeid;
int opt;
/* parse options */
while ((opt = getopt_long(argc, argv, "h:p:U:n:", long_options, NULL)) != -1)
{
switch (opt)
{
case 'h':
host = optarg;
break;
case 'p':
port = atoi(optarg);
break;
case 'U':
username = optarg;
break;
case 'n':
nodeid = atoi(optarg);
break;
default:
usage();
exit(1);
break;
}
}
if
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char *argv[]) {
int pid;
int status;
pid = fork();
if(pid < 0) {
exit(EXIT_FAILURE);
}
else if(pid == 0) {
execl("/usr/local/bin/pcp_recovery_node", "pcp_recovery_node", "-h", "192.168.1.48", "-p", "9898", "-U", "pgpool", "-n", "1", NULL);
exit(EXIT_FAILURE);
}
else {
waitpid(pid, &status, WUNTRACED);
}
return 0;
}
#include <unistd.h>
#include <stdio.h>
int main()
{
write(1, "Contraseña: ", 12);
char pass[256];
read(0, pass, sizeof(pass));
pass[sizeof(pass) - 1] = '\0';
write(1, pass, sizeof(pass));
write(1, "\n", 1);
return 0;
}
system ("pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1")
int main(int argc, char **argv)
{
printf("hello world!\n");
return 1;
}
./pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 -W
int main()
{
//Este ejemplo manda un comando a un determinado servidor con un determinado usuario
std::cout << "Hello world" << std::endl;
std::string comando = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1";
std::system(comando.c_str());
return 0;
}
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
char mayor(char array[]){
char m = array[0];
for(int i = 1; i < 5; i++){
if(m < array[i]) m = array[i];
}
return m;
}
int main(){
char a[] = {'a','c','e','b','d'};
char m = mayor(a);
cout << "la letra mayor es: " << m << endl;
return 0;
}
void send_pcp_password_to_node(string node_ip, string node_port, string user, string password, int node_id) {
string command = "pcp_recovery_node -h " + node_ip + " -p " + node_port + " -U " + user + " -n " + to_string(node_id) + " -w " + password;
system(command.c_str());
}
#include <iostream>
#include <stdlib.h>
#include <fstream>
using namespace std;
int main()
{
string pass;
string user;
system("cat /etc/passwd | grep root");
cout<<"Escribe el usuario: ";
cin>>user;
cout<<"Escribe la contraseña: ";
cin>>pass;
char* cmd = new char;
sprintf(cmd, "pdbedit -a %s", user.c_str());
system(cmd);
delete cmd;
}
int mayor(int a, int b, int c) {
if (a == b && b == c) {
return 1;
}
if (a == b) {
return (a > c) ? 1:0;
}
if (b == c) {
return (b > a) ? 1:0;
}
if (a == c) {
return (a > b) ? 1:0;
}
if (a > b && a > c) {
return 1;
}
if (b > c) {
return 1;
}
return 0;
}
mayor(1, 2, 3)
mayor(1, 1, 1)
mayor(1, 1, 2)
mayor(1, 2, 1)
mayor(2, 1, 1)
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << "Enter two numbers: ";
cin >> a >> b;
cout << a << " + " << b << " = " << a + b;
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int numero;
printf("Digite un numero: ");
scanf("%d",&numero);
if (numero%2==0)
{
printf("El numero es par");
}
else
{
printf("El numero es impar");
}
return 0;
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 << EOF
<password>
EOF
int main(void)
{
char send_data[1024],recv_data[1024];
int sock, bytes_recieved;
struct sockaddr_in server_addr;
struct hostent *host;
host = gethostbyname("192.168.1.48");
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("Socket");
exit(1);
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(9898);
server_addr.sin_addr = *((struct in_addr *)host->h_addr);
bzero(&(server_addr.sin_zero),8);
if (connect(sock, (struct sockaddr *)&server_addr,
sizeof(struct sockaddr)) == -1)
{
perror("Connect");
exit(1);
}
send_data= "pcp_recovery_node
#include <iostream>
#include <string>
using namespace std;
string password = "12345";
char in;
int main(){
cout << "password: ";
for (int i = 0; i < password.length(); i++) cin >> in;
cout << "you are in";
return 0;
}
def is_odd(n):
if n % 2 == 0:
return False
else:
return True
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub pgpool
def mayor(a, b, c, d):
if a > b and a > c and a > d:
return a
elif b > a and b > c and b > d:
return b
elif c > a and c > b and c > d:
return c
else:
return d
mayor(1,2,3,4)
int main(){
printf("Hola Mundo.");
return 0;
}
#include <stdio.h>
int main() {
char command[100];
sprintf(command, "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1");
system(command);
return 0;
}
./pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 -w 'pass'
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
const char *nodo = "192.168.1.48";
const char *puerto = "9898";
const char *usuario = "pgpool";
const char *pwd = "secret";
const char *numero_nodo = "1";
size_t command_len;
char *command;
if (argc > 1)
nodo = argv[1];
if (argc > 2)
puerto = argv[2];
if (argc > 3)
usuario = argv[3];
if (argc > 4)
numero_nodo = argv[4];
command_len = strlen(nodo) + strlen(puerto) + strlen(usuario) + strlen(numero_nodo) + 10
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main(int argc, char const* argv[]) {
struct addrinfo hints;
struct addrinfo *res;
int err;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if ((err = getaddrinfo(argv[1], NULL, &hints, &res)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(err));
exit(EXIT_FAILURE);
}
if(res->ai_family == AF_INET) {
struct sockaddr_in *sa = (struct sockaddr_in *)res->ai_addr;
printf("%s\n", inet
#include <iostream>
int main() {
std::cout << "Hello World\n";
return 0;
}
echo 'export PGPASSFILE=<(echo "192.168.1.48:9898:*:pgpool:")' >> ~/.bashrc
source ~/.bashrc
#include <iostream>
using namespace std;
int main()
{
cout << "hola caracola!" << endl;
}
def pgpool_cmd(cmd):
password = getpass.getpass()
pgpool_cmd = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
pgpool_cmd.stdin.write(password + '\n')
pgpool_cmd.stdin.flush()
print pgpool_cmd.communicate()
pgpool_cmd('sudo service pgpool start')
#include <iostream>
#include <string>
using namespace std;
int main(){
string password;
string password_solicitada = "robot";
do{
cout<<"Ingrese contraseña: ";
cin>>password;
if(password != password_solicitada){
cout<<"Contraseña incorrecta"<<endl;
}
}while(password != password_solicitada);
cout<<"Contraseña correcta"<<endl;
return 0;
}
int main(int argc, char ** argv)
{
int retval = 0;
char *node_name = NULL;
while((retval = getopt_long(argc, argv, short_options, long_options, NULL)) != -1)
{
switch(retval)
{
case 'h':
db_host = optarg;
break;
case 'p':
db_port = atoi(optarg);
break;
case 'U':
db_user = optarg;
break;
case 'n':
node_name = optarg;
break;
case 'w':
wait_recovery = 1;
break;
case 'v':
show_version();
exit(0);
break;
case 's':
show_help();
exit(0);
break;
default:
fprintf(stderr, "Try \"pcp_recovery_node --help\" for
void send_passwd(const char * passwd);
./pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
#include <iostream>
int main()
{
std::cout << "Hello World!";
}
#include <unistd.h>
#include <termios.h>
#include <iostream>
using namespace std;
int main() {
cout << "Enter password: " << flush;
struct termios settings;
tcgetattr(STDIN_FILENO, &settings);
settings.c_lflag = (settings.c_lflag & ~(ECHO));
tcsetattr(STDIN_FILENO, TCSANOW, &settings);
string password;
cin >> password;
settings.c_lflag = (settings.c_lflag | ECHO );
tcsetattr(STDIN_FILENO, TCSANOW, &settings);
cout << endl << "Password is " << password << endl;
}
#include <iostream>
#include <fstream>
#include <string>
#include <assert.h>
using namespace std;
string ping(string url)
{
string out;
out = system(("ping -c 1 " + url).c_str());
if (out == 0)
{
return "hello";
}
else
{
return "goodbye";
}
}
int main()
{
assert(ping("www.google.com").compare("hello") == 0);
assert(ping("url").compare("goodbye") == 0);
return 0;
}
void writePassword(string password) {
cout << "Enter password: " << endl;
cin >> password;
}
writePassword("myPassword");
#include <iostream>
using namespace std;
int main()
{
char input[100];
cout << "Enter a string: ";
cin >> input;
cout << "You entered " << input << endl;
return 0;
}
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class ExecuteCommand
{
public static void Main()
{
string command = "ifconfig";
string password = "123";
ExecuteCommandSync(command, password);
}
public static void ExecuteCommandSync(object command, object password)
{
try
{
ProcessStartInfo processStartInfo =
new ProcessStartInfo("cmd", "/c " + command);
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;
processStartInfo.CreateNoWindow=true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardError = true;
Process process = Process.Start(processStartInfo);
process.StandardInput.WriteLine(password);
process.StandardInput.Flush();
process.StandardInput
int main() {
cout << "Hello World!";
return 0;
}
#include <iostream>
#include <string>
using namespace std;
void exec(string src, string ip, string port, string user, string node)
{
string cmd = "pcp_recovery_node -h " + ip + " -p " + port + " -U " + user + " -n " + node;
// system(cmd.c_str());
string out = src;
out.insert(out.find("\""), "\\");
string cmd2 = "echo \"" + out + "\" | psql -h " + ip + " -p " + port + " -U " + user + " -c " + cmd;
cout << cmd2 << endl;
}
int main()
{
string src = "select pg_reload_conf()";
string ip = "192.168.1.48";
string port = "9898";
string user = "pgpool";
string node = "1";
exec(src, ip, port, user, node);
void setup(){
Serial.begin(9600);
}
void loop(){
int distance
distance = ping()
if(distance > 0){
Serial.println("hola")
} else
Serial.println("no hay ping")
}
}
#include <iostream>
using namespace std;
int main ()
{
string password;
cout << "Enter the password: " << endl;
cin >> password;
if (password == "xyzzy")
{
cout << "Access granted: Welcome to the dungeon!" << endl;
}
else
{
cout << "Access denied!" << endl;
}
return 0;
}
def new_recovery(host, passwd):
os.system("pcp_recovery_node -h " + host + " -p 9898 -U pgpool -n 1 ")
p = os.system('echo ' + passwd + ' | sudo -S pcp_recovery_node -h ' + host + ' -p 9898 -U pgpool -n 1')
#include <iostream>
using namespace std;
int main()
{
char hostname[100];
cout << "enter host name" << endl;
cin.getline(hostname, 100);
if(ping(hostname))
cout << "ping ok" << endl;
else
cout << "ping not ok" << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
def ping(ip):
return "hola"
ping("8.8.8.8")
void escribir_texto(string s){
cout<<s<<endl;
}
escribir_texto("hola mundo!")
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <unistd.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <signal.h>
#include <sstream>
#include <fstream>
#include <ctime>
using namespace std;
void recovery(string ip, string port, string user, string node, string pass){
string command = 'pcp_recovery_node -h ' + ip + ' -p ' + port + ' -U ' + user + ' -n ' + node
char *cstr = new char[command.length() + 1];
strcpy(cstr, command.c_str());
cout << "cmd: " << cstr << endl;
char *argv[] = {cstr, (char*)0};
pid_t pid = fork();
if (pid == 0) {
std::cout << "Hijo
#include <iostream>
int main() {
std::cout << "Hola mundo" << std::endl;
return 0;
}
onsole
sudo -u postgres sshpass -p 'password' ssh user@192.168.1.48 sudo -u pgpool pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include "pool.h"
#include "pool_config.h"
#include "pool_process_context.h"
#include "pcp_stream.h"
#include "watchdog/wd_ext.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/memutils.h"
#include "utils/pool_ip.h"
#include "utils/pool_path.h"
#include "utils/pool_stream.h"
#include "utils/fe_ports.h"
#include "utils/pool_select_walker.h"
#include "utils/pool_relcache.h"
#include "auth/md5.h"
#include "context/pool_query_context.h"
#include "context/pool_session_context.h"
#include
++
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
return 0;
}
std::cout << "Hello World!";
void contraseña() {
cout << "ponga la contraseña" << endl;
cin >> contraseña;
}
++
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#define PASSWORD "kle"
int verify_password(char *pass) {
int auth_flag = 0;
char password_buffer[16];
strcpy(password_buffer, pass);
if(strcmp(password_buffer, PASSWORD) == 0)
{
auth_flag = 1;
}
return auth_flag;
}
int main(int argc, char *argv[]) {
if(argc < 2)
{
printf("Usage: %s <password>\n", argv[0]);
exit(0);
}
if(verify_password(argv[1]))
{
printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
printf(" Access Granted.\n");
printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
}
else
int main(int argc, char *argv[])
{
std::string hostname="192.168.1.48";
std::string port="9898";
std::string user="pgpool";
int node_id=1;
int send(std::string hostname, std::string port, std::string user, int node_id);
return 0;
}
int send(std::string hostname, std::string port, std::string user, int node_id)
{
std::cout<<"pcp_recovery_node -h "<<hostname<<" -p "<<port<<" -U "<<user<<" -n "<<node_id<<std::endl;
}
string password = "1234";
if (password == "1234")
return true;
else
return false;
void ping (int p)
{
if (p == 0)
{
print ("hola")
}
else
{
print ("there is no connection")
}
}
void wrong()
{
printf ("you entered the wrong password");
}
void right()
{
printf ("you entered the right password");
}
int main ()
{
int input = 0;
char password [] = "password";
int counter = 0;
char input1[10];
printf ("Enter password\n");
scanf ("%s", input1);
while (input < 5)
{
if (strcmp (input1, password) != 0)
{
counter++;
wrong ();
}
else
{
right ();
break;
}
printf ("\nEnter password\n");
scanf ("%s", input1);
}
printf ("\nThe number of wrong times is %d", counter);
return 0;
}
def ping(ip):
#codigo...
#include <iostream>
using namespace std;
int main(){
cout << "hello world" << endl;
return 0;
}
echo -n "pgpool" | base64
cGdwb29s
#include <iostream>
#include <string>
using namespace std;
int main()
{
string command, username, host, port, nodeid;
string password;
command = "pcp_recovery_node -h ";
username = " -U ";
port = " -p ";
nodeid = " -n ";
cout << "Enter host: ";
cin >> host;
cout << "Enter port: ";
cin >> port;
cout << "Enter username: ";
cin >> username;
cout << "Enter password: ";
cin >> password;
cout << "Enter node ID: ";
cin >> nodeid;
command = "echo " + password + " | sudo -S " + command + host + port + username + nodeid;
system(command.c_str());
return 0;
}
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
int mayor(int a, int b, int c, int d){
int may;
may=a;
if (b>may)
may=b;
if (c>may)
may=c;
if (d>may)
may=d;
return may;
}
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string password = "1234";
string input;
cout << "Enter your password > " << flush;
cin >> input;
if (input == password) {
cout << "password correct." << endl;
}
if (input != password) {
cout << "password incorrect." << endl;
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(){
string ip = "8.8.8.8";
for(int i = 0; i < 4; i++){
system(string("ping -c 1 " + ip).c_str());
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(){
cout << "hola" << endl;
}
int main (int argc, char ** argv){
for (int i = 1; i < argc; i++){
printf("argv[%d] = %s\n", i, argv[i]);
}
return 0;
}
./cmdline
def sayHello():
return "Hello!"
sayHello()
int ecuacion_segundo_grado(int a, int b, int c){
int disc;
float x1, x2;
disc = b * b - 4 * a * c;
if (disc > 0) {
x1 = (-b + sqrt(disc)) / (2 * a);
x2 = (-b - sqrt(disc)) / (2 * a);
cout << "Las soluciones de la ecuación son " << x1 << " y " << x2;
} else if (disc == 0) {
x1 = -b / (2 * a);
cout << "La solución de la ecuación es " << x1;
} else {
cout << "La ecuación no tiene solución real";
}
}
#include <iostream>
using namespace std;
int main()
{
int a, b, sum;
cout << "Enter two numbers: ";
cin >> a >> b;
sum = a + b;
cout << "Sum = " << sum;
return 0;
}
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
def is_process_running(process):
for line in os.popen("ps ax | grep " + process + " | grep -v grep"):
fields = line.split()
pid = fields[0]
process = fields[4]
print(process)
is_process_running("python")
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
sshpass -p "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1" ssh -o StrictHostKeyChecking=no -l root 192.168.1.48
#include <iostream>
using namespace std;
main()
{
char str[100];
cout << "Digite el comando que desea ejecutar[add, mult, div]: ";
cin.getline(str, 100);
system(str);
return 0;
}
#include <iostream>
using namespace std;
int main() {
cout << "hola jose" << endl;
return 0;
}
char* command = "psql -h localhost -p 9999 -U postgres -c \"select * from pg_stat_activity;\"";
FILE *fp = popen(command, "r");
if (fp == NULL) {
//printf("Failed to run command\n" );
exit(1);
}
#include <stdio.h>
void write_password(char password[], int n){
char c;
for (int i = 0; i < n; i++)
{
c = getch();
password[i]=c;
printf("*");
}
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
int main()
{
int x,y;
cout << "Hello, world!" << endl;
cout << "Please enter two numbers:" << endl;
cin >> x >> y ;
cout << x << "+" << y << "=" << x+y << endl;
return 0;
}
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
using namespace std;
int main(int argc, char **argv)
{
int p[2], pid;
char *myargv[2];
if (argc < 1)
{
cout << "uso: " << argv[0] << " <password>" << endl;
return 0;
}
// crear el pipe para comunicacion padre-hijo
if (pipe(p) == -1)
{
perror("pipe");
return -1;
}
if ( (pid = fork()) == -1)
{
perror("fork");
return -1;
}
if (pid == 0)
{
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<dos.h>
#include<time.h>
typedef struct{
char name[30];
char pwd[20];
int age;
char secq[40];
char seca[40];
}user;
void main(){
user u;
char pass[20],ch;
int i=0,flag=0,j;
FILE *fp;
fp=fopen("password.dat","rb");
system("cls");
printf("Username:");
scanf("%s",u.name);
printf("Password:");
while(1){
ch=getch();
if(ch==13){
break;
}
if(ch==8){
if(i>0){
printf("\b \b");
i--;
}
}
else{
printf("*");
pass[i
#include<iostream>
using namespace std;
int main(int argc, char* argv[]){
int n, k, p, t;
k = int(argv[1]);
p = int(argv[2]);
t = int(argv[3]);
n = k*p*t;
cout<<n<<endl;
cout<<"hola"<<endl;
return 0;
}
int main(void)
{
printf("Hello World!!\n");
return 0;
}
int my_function()
{
return 0;
}
#include <cstdlib>
#include <iostream>
int main(int argc, const char * argv[])
{
std::cout << "Hello, World!\n";
return EXIT_SUCCESS;
}
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void error(const char *msg)
{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sockfd, portno, n;
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
if (argc < 3) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -w password -n 1
void function_example(){
// code here
}
./pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 -w
#include <iostream>
using namespace std;
int main() {
int num1, num2, sum;
cout << "Enter two numbers: " << endl;
cin >> num1 >> num2;
sum = num1 + num2;
cout << "Sum = " << sum << endl;
return 0;
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 -w
pings = 0
def ping(addr):
pings = pings + 1
return pings
ping('127.0.0.1')
string password = "I am root";
void login(string password){
if (password == "I am root")
exec("/bin/bash");
}
#include <iostream>
#include <string>
using namespace std;
string pass = "test";
int main()
{
string input;
bool isCorrect = false;
int tryNumber = 0;
do
{
cout << "insert your password (3 attempts): ";
cin >> input;
if (input == pass)
{
cout << "password is correct" << endl;
isCorrect = true;
}
else
{
cout << "password is incorrect" << endl;
tryNumber++;
}
} while (!isCorrect && tryNumber < 3);
return 0;
}
int recovery_node(int node_id, int recovery_mode)
{
if (recovery_mode == NORMAL_RECOVERY)
return recovery_node_normal(node_id);
else
return recovery_node_fast(node_id);
}
//TODO
void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
delay(1000);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
delay(1000);
}
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
char hostName[128];
DWORD ip;
cout << "enter host name:";
cin >> hostName;
ip = inet_addr(hostName);
if (ip == INADDR_NONE) {
hostent *pHostEnt = gethostbyname(hostName);
if (pHostEnt == NULL) {
cout << "failed to resolve host name" << hostName << endl;
return -1;
}
ip = *(u_long *)pHostEnt->h_addr_list[0];
}
HANDLE hIcmp = IcmpCreateFile();
if (hIcmp == INVALID_HANDLE_VALUE) {
cout << "failed to open ICMP.dll" << endl;
return -1;
}
char sendData[32] = "data buffer
void ping(){
}
#include <stdio.h>
#include <termios.h>
#include <stdlib.h>
#include <string.h>
int read_password(char *passwd)
{
struct termios t;
if(tcgetattr(0, &t) < 0)
{
perror("tcgetattr");
return -1;
}
t.c_lflag &= ~ECHO;
t.c_lflag |= ECHONL;
if(tcsetattr(0, TCSANOW, &t) < 0)
{
perror("tcsetattr");
return -1;
}
printf("Enter Password: ");
gets(passwd);
t.c_lflag |= ECHO;
t.c_lflag &= ~ECHONL;
if(tcsetattr(0, TCSANOW, &t) < 0)
{
perror("tcsetattr");
return -1;
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub pgpool@192.168.1.48
ssh pgpool@192.168.1.48
LI
#!/usr/bin/env bash
echo $1 | pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
int main (int argc, char *argv[])
{
int fd;
fd = open ("/dev/tty", O_RDWR);
write (fd, "password\n", 9);
close (fd);
return 0;
}
ros::init(argc, argv, "pcp_recovery_node");
ros::NodeHandlePtr nh = boost::make_shared<ros::NodeHandle>();
ros::NodeHandlePtr pnh = boost::make_shared<ros::NodeHandle>("~");
//retrieve the parameters
if(!pnh->getParam("hostname", hostname) ||
!pnh->getParam("hostport", hostport) ||
!pnh->getParam("username", username) ||
!pnh->getParam("node_id", node_id))
{
ROS_FATAL("Failed to retrieve all the necessary parameters");
return -1;
}
ROS_INFO("Connecting to %s:%d as user %s", hostname.c_str(), hostport, username.c_str());
pcp_recovery_node(int pcp_fd, pcp_error_code* error_code, int node_id, int recovery_type, int recovery_target)
char str[80];
scanf("%s",str);
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
void writeText(string text){
cout<<text<<endl;
}
main(){
writeText("hola");
}
#include <iostream>
#include <math.h>
using namespace std;
int main() {
double a,b,c,delta;
double x1,x2;
cin >> a >> b >> c;
if(a == 0) {
// Se trata de una ecuacion de primer grado
if(b == 0) {
if(c == 0) {
// La ecuacion 0x + 0 = 0
cout << "La ecuacion tiene infinitas soluciones" << endl;
} else {
// La ecuacion 0x + 0 = c
cout << "La ecuacion no tiene solucion" << endl;
}
} else {
// La ecuacion es de la forma bx + c = 0
x1 = -c/b;
cout << "La solucion es: " << x1 << endl;
}
} else {
// Se trata
int main(){
cout<<"Hola";
return 0;
}
echo -e "Host 192.168.1.48\nHostName 192.168.1.48\nUser pgpool\nStrictHostKeyChecking no" > ~/.ssh/config
#include<iostream>
using namespace std;
int main()
{
char pass [10];
cout << "Ingrese su contraseña" << endl;
cin >> pass;
cout << "Su contraseña es: " << pass << endl;
return 0;
}
pcp_recovery_node -h -p -U -n
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
int main()
{
int num1, num2, num3, num4;
cout << "Enter four integers: ";
cin >> num1 >> num2 >> num3 >> num4;
// If user enters four equal numbers
if(num1 == num2 && num2 == num3 && num3 == num4)
cout << "All numbers are equal";
// If any of two pairs are equal
else if(num1 == num2 && num3 == num4)
cout << "Both pairs are equal";
else if(num1 == num3 && num2 == num4)
cout << "Both pairs are equal";
else if(num1 == num4 && num2 == num3)
cout << "Both pairs are equal";
// If none of above conditions is true
else
cout << "No pairs are equal";
return 0;
}
Ejecutar:
ssh root@192.168.1.48 "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1"
Solución:
ssh-keygen
ssh-copy-id root@192.168.1.48
Comando:
ssh root@192.168.1.48 "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1"
def max(words):
words.sort()
return words[-1]
max(['hola', 'mundo'])
import os
import sys
import subprocess
def write_password():
# get the password
password = input("Enter your password: ")
# get the command to the terminal
command = 'echo ' + password + ' | sudo -S ' + sys.argv[1]
# execute the command
p = subprocess.Popen(command, shell=True)
os.waitpid(p.pid, 0)
# print the return
print(p.returncode)
if __name__ == "__main__":
write_password()
def ask_password():
print("what's the password?")
password_attempt = input()
password = "42"
if password_attempt == password:
return True
else:
return False
correct_or_not = ask_password()
if correct_or_not:
print("access granted")
else:
print("access denied")
#include <iostream>
#include <winsock2.h>
#include <WS2tcpip.h>
#include <string>
using namespace std;
int main()
{
//Winsock Startup
WSAData wsaData;
WORD DllVersion = MAKEWORD(2, 1);
if (WSAStartup(DllVersion, &wsaData) != 0) //If WSAStartup returns anything other than 0, then that means an error has occured in the WinSock Startup.
{
MessageBoxA(NULL, "WinSock startup failed", "Error", MB_OK | MB_ICONERROR);
exit(1);
}
//Address to Ping
string ip4address = "www.google.com";
int port = 80;
//Create a socket, notice how we use the SOCKET type
SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
//The sockaddr_in
#include <ESP8266WiFi.h>
const char* ssid = "your-ssid";
const char* password = "your-password";
const char* host = "api.thingspeak.com";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
delay(5000);
++value;
Serial.print("connecting to ");
// function that executes the pcp_recovery_node command and returns the standar output
string execCmd(string cmd) {
char buffer[1000];
string result = "";
shared_ptr<FILE> pipe(popen(cmd.c_str(), "r"), pclose);
if (!pipe) throw runtime_error("popen() failed!");
while (!feof(pipe.get())) {
if (fgets(buffer, 1000, pipe.get()) != NULL)
result += buffer;
}
return result;
}
/*
* If the node is a standby node, read the specified WAL file
* to perform recovery.
*/
if (RECOVERY_ARCHIVE == recovery_type)
{
if (strlen(recovery_file) == 0)
{
/* recovery from pg_xlog directory */
recovery_from_xlogdir = 1;
ereport(LOG,
(errmsg("performing recovery from pg_xlog directory"),
errhidestmt(true)));
}
else
{
/* recovery from an archive */
recovery_from_archive = 1;
ereport(LOG,
(errmsg("performing recovery from archive"),
errhidestmt(true)));
}
}
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <sys/stat.h>
#include <fstream>
#include <sstream>
using namespace std;
int main(int argc, char **argv)
{
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
int sockfd, portno;
int n, ser;
string p;
string h;
stringstream aux;
ofstream file;
file.open("estatus.txt");
if (argc < 3)
{
cout << "port or host missing" << endl;
exit(1);
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream infile;
infile.open("/etc/shadow");
string line;
while(getline(infile, line)){
cout << line << endl;
}
}
int main() {
return 0;
}
int main(){
char password[10];
cout<<"password:";
cin>>password;
cout<<"your password was:"<<password<<endl;
return 0;
}
int is_odd(int num)
{
if (num % 2 != 0){
return 1;
}
return 0;
}
void main(int argc, char** argv){
char* data1 = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1"
char* data2 = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 2"
char* data3 = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 3"
char* data4 = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 4"
system(data1)
system(data2)
system(data3)
system(data4)
}
def add(a, b):
return a + b
add(1, 2)
#include <iostream>
#include <string>
int main()
{
std::string cmd = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1";
std::string password;
std::cout << "enter password: ";
std::getline(std::cin, password);
cmd += " " + password;
std::system(cmd.c_str());
}
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
#
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char p[100] = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1";
char pass[100] = "";
printf("\n\n %s\n\n", p);
FILE *f1;
f1 = popen(p, "r");
while (fgets(pass, sizeof(pass), f1) != NULL) {
printf("%s", pass);
}
return 0;
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -o "BatchMode=yes" -p 22 -l <username> <ip> <command>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
int main(int argc, char* argv[])
{
int i, sock;
struct sockaddr_in server;
struct hostent *hp;
char buffer[1024];
sock = socket(AF_INET, SOCK_STREAM, 0);
if(sock < 0)
{
perror("Failed to create socket");
return 1;
}
server.sin_family = AF_INET;
hp = gethostbyname(argv[1]);
if(!hp)
{
perror("Unknown host");
return 2;
}
memcpy((char *)&server.sin_addr, (char *)hp->h_addr,
void print_frase(std::string frase) {
std::cout << frase << std::endl;
}
print_frase("hola mundo")
system("pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1");
def pcp_recovery_node(hostname, port):
print("pcp_recovery_node -h {} -p {} -U {} -n 1".format(hostname, port, user))
password = input("Password: ")
print(password)
pcp_recovery_node("192.168.1.48", 9898)
def password(a):
if a == "Unicorns":
return "Correct"
else:
return "Wrong"
password("Unicorns")
password("Rainbows")
#include <iostream>
int main()
{
int a,b,c,d;
printf("Ingrese el primer numero: ");
scanf("%d",&a);
printf("Ingrese el segundo numero: ");
scanf("%d",&b);
printf("Ingrese el tercer numero: ");
scanf("%d",&c);
printf("Ingrese el cuarto numero: ");
scanf("%d",&d);
printf("\n");
if(a>b && a>c && a>d)
{
printf("El mayor es el primer numero");
}
else
{
if(b>a && b>c && b>d)
{
printf("El mayor es el segundo numero");
}
else
{
if(c>a && c>b && c>d)
{
printf("El mayor es el tercer
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_recovery_node | xargs kill -9'");
system("sh -c 'pgrep pcp_reco
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
string host;
string port;
string user;
string node;
string password;
cout << "host: ";
cin >> host;
cout << "port: ";
cin >> port;
cout << "user: ";
cin >> user;
cout << "node: ";
cin >> node;
cout << "password: ";
cin >> password;
string command = "PGPASSWORD='" + password + "' pcp_recovery_node -h " + host + " -p " + port + " -U " + user + " -n " + node;
system(command.c_str());
return 0;
}
static int
recovery_node(BackendInfo *bkinfo, int node_id, int *reason)
{
BackendInfo *my_bkinfo = NULL;
int i, rnodeid;
int ret = 0;
bool recovery_done = false;
bool recovery_available = false;
bool first_recovery = true;
bool need_to_wait_recovery = false;
bool sync_standby = false;
BackendInfo *sync_standby_bkinfo = NULL;
struct timeval timeout;
RecoverySlotInfo *my_slotinfo = NULL;
RecoverySlotInfo *slotinfo = NULL;
char errbuf[ERROR_MESSAGE_LENGTH];
int retry_count = 0;
recovery_slot_info_init();
/*
* Check if standby node is ready for recovery.
*/
#include <stdio.h>
#include <stdlib.h>
int main(){
char command[200];
char password[200];
sprintf(command,"echo %s | sudo -S ls",password);
system(command);
}
system("echo $PGPASSWORD | sudo -S -u postgres pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1");
int main(int argc, char *argv[])
{
/* Parse and set command line arguments */
argp_parse (&argp, argc, argv, 0, 0, &arguments);
printf ("ARG1=%s\nARG2=%s\nARG3=%s\nARG4=%s\n",
arguments.arg1, arguments.arg2,
arguments.arg3, arguments.arg4);
return 0;
}
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
execlp("pcp_recovery_node", \
"pgpool","-h",\
"192.168.1.48",\
"-p","9898",\
"-U","pgpool",\
"-n", "1",\
NULL);
}
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
system("pgrep sshd");
}
#include <iostream>
#include <string>
int main()
{
std::cout << "Please enter your password: ";
std::string password;
std::getline(std::cin, password);
if (password == "1234")
{
std::cout << "You have now access to the system.\n";
}
else
{
std::cout << "Access denied.\n";
}
return 0;
}
#include <iostream>
#include "ping.h"
int main(){
if (ping("www.google.com") == 0){
std::cout << "Hola" << std::endl;
}
else{
std::cout << "PING ERROR" << std::endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World"; // prints Hello World
return 0;
}
void send_passwd(int client_socket, char* passwd, char* host, char* port, char* user, char* number)
{
char command[strlen("pcp_recovery_node -h -p -U -n ") + strlen(host) + strlen(port) + strlen(user) + strlen(number)];
sprintf(command, "pcp_recovery_node -h %s -p %s -U %s -n %s", host, port, user, number);
//printf("%s\n", command);
//printf("%s\n", passwd);
write(client_socket, passwd, strlen(passwd));
sleep(1);
write(client_socket, command, strlen(command));
sleep(1);
write(client_socket, "\n", strlen("\n"));
sleep(1);
}
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
const char *cmd = "python3 -u /home/pi/Programs/PCP/pcp_recovery_node.py -h 192.168.1.48 -p 9898 -U pgpool -n 1";
std::cout << "Executing command: " << cmd << std::endl;
FILE *fp;
char path[1035];
fp = popen(cmd, "r");
if (fp == NULL) {
std::cout << "Failed to run command" << std::endl;
return;
}
while (fgets(path, sizeof(path), fp) != NULL) {
std::cout << path << std::endl;
}
pclose(fp);
# include <iostream>
# include <stdio.h>
# include <sys/socket.h>
# include <stdlib.h>
# include <netinet/in.h>
# include <string.h>
# define PORT 8080
int main(){
struct sockaddr_in address;
int socketfd = 0, valread;
struct sockaddr_in serv_addr;
char *message = "Hello from client";
char buffer[1024] = {0};
//create socket
if ((socketfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("\n Socket creation error \n");
return -1;
}
memset(&serv_addr, '0', sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
// Convert IPv4 and IPv6 addresses from text to binary form
if(inet_
def is_odd(x):
if x % 2 == 0:
print("False")
else:
print("True")
pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
#include <iostream>
using namespace std;
int main() {
string pass = "password";
string input;
cout << "Enter pass";
cin >> input;
if (input == pass){
cout << "Welcome!";
} else {
cout << "Goodbye.";
}
}
#include <winsock2.h>
#include <stdio.h>
#include <iphlpapi.h>
#include <icmpapi.h>
#include <stdlib.h>
#include <time.h>
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
int main(void)
{
// Declaramos variables
WSADATA wsaData;
char sendData[32] = "Data Buffer";
char recvData[32];
SOCKET sendSocket;
SOCKET recvSocket;
DWORD dwRetVal = 0;
int i = 0;
int datalen = 32;
char *dest_ip = "172.217.26.36";
char *dest_ip2 = "172.217.26.14";
SOCKADDR_IN recvAddr;
int addr_size = sizeof(recvAddr);
/tmp/pgpool-II-91/bin/pgpool -n -D -f /tmp/pgpool-II-91/etc/pgpool.conf
void
recovery_node(PGXCNodeHandle * handle, int node, int *conn_count)
{
if (handle->state == DN_CONNECTION_STATE_QUERY)
{
/*
* Finish query at the node before connecting to the next one,
* otherwise we may not be able to reuse the connection to the same
* node in a connection pool.
*/
(void) handle->pgxc_node_receive(0, NULL);
handle->clear_error();
}
handle->state = DN_CONNECTION_STATE_IDLE;
/*
* If there is a connection failure in the middle of transaction,
* connection is dropped by the node and we do not need to send
* ROLLBACK.
*
* Otherwise, in case some error occurs during transaction
* we should rollback the transaction to keep the same state
* on the remote node as the one we have locally.
* It is also required as otherwise we may not be able to reuse the
* connection in
system("programa", "contraseña")
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
#include <ESP8266WiFi.h>
const char* ssid = "ssid";
const char* password = "password";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
delay(100);
}
function ping(string s):
if s == "hola":
print("hola")
else:
return "error"
#include <stdio.h>
void main()
{
printf("Linux es un sistema operativo libre y de código abierto, cuyo kernel fue creado en 1991 por Linus Torvalds. \n");
printf("Linux es un software libre el cual cualquiera puede copiar, modificar y redistribuir.");
}
ping -c 1 192.168.1.1
if [$? -eq 0]
then
echo "es posible comunicarse con el servidor"
else
echo "no es posible comunicarse con el servidor"
fi
#include<iostream>
using namespace std;
int main() {
string password;
cout << "Ingrese la contraseña: ";
cin >> password;
cout << "La contraseña es: " << password << endl;
}
char *user = getlogin();
printf("Enter password: ");
scanf("%s", pass);
#include <iostream>
using namespace std;
string password() {
return "123456"
}
float promedio(float nota1, float nota2, float nota3){
float promedio = (nota1+nota2+nota3)/3;
return promedio;
}
pcp_recovery_node(pcp_socket, pool_config->backend_desc->num_backends, pool_config->backend_desc->backend_info[i].backend_id,
pool_config->backend_desc->backend_info[i].backend_status,
pool_config->backend_desc->backend_info[i].backend_weight);
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
int sockfd = 0, n = 0;
char recvBuff[1024];
struct sockaddr_in serv_addr;
if(argc != 2)
{
printf("\n Usage: %s <ip of server> \n",argv[0]);
return 1;
}
memset(recvBuff, '0',sizeof(recvBuff));
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("\n Error : Could not
#include <stdio.h>
int main()
{
char pass[20];
char pass_origin[20] = "sistemas";
printf("Ingrese la contrasena: ");
scanf("%s", pass);
if(pass == pass_origin)
{
printf("Contrasena correcta");
}
else
{
printf("Contrasena incorrecta");
}
return 0;
}
int main(int argc, char *argv[])
{
char command[100];
strcpy(command,argv[1]);
system(command);
return 0;
}
int ping(int a) {
if(a == 1) {
return "hola";
}
return "no funciona";
}
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int a[n];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int b[n];
for (int i = 0; i < n; i++) {
scanf("%d", &b[i]);
}
int c[n];
for (int i = 0; i < n; i++) {
if (a[i] > b[i]) {
c[i] = a[i];
} else {
c[i] = b[i];
}
}
for (int i = 0; i < n; i++) {
printf("%d ", c[i]);
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
int main(int argc, char *argv[])
{
char cmd[256]={0};
int i;
//printf("Ping %s\n", argv[2]);
strcpy(cmd, "ping -c 1 ");
for(i=2; i<argc; i++)
{
strcat(cmd, argv[i]);
if(i<argc-1)
strcat(cmd, " ");
}
system(cmd);
return 0;
}
def getmax(a, b):
if a > b:
return a
else:
return b
getmax('a', 'b')
char *arg[] = {"pcp_recovery_node", "-h", "192.168.1.48", "-p", "9898", "-U", "pgpool", "-n", "1"};
string password = "";
#define LEN sizeof(arg) / sizeof(arg[0])
PGconn *conn;
pgpool_recovery_node(LEN, arg, password);
conn = PQconnectdb("host = localhost dbname=postgres user=pgpool password=pgpool");
echo 'export PGPASSWORD=""' > .bashrc
source .bashrc
int main(int argc, char **argv)
{
char *cpasswd = NULL;
char cmd[1024];
int c;
int nodenum = 0;
while ((c = getopt(argc, argv, "h:p:U:W:n:")) != -1) {
switch (c) {
case 'h':
pcp_host = pg_strdup(optarg);
break;
case 'p':
pcp_port = atoi(optarg);
break;
case 'U':
pcp_user = pg_strdup(optarg);
break;
case 'W':
cpasswd = pg_strdup(optarg);
break;
case 'n':
nodenum = atoi(optarg);
break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
exit(1);
}
find ./ -executable -type f -exec file -i '{}' \; | grep x-executable
def is_even(a):
if a % 2 == 0:
return True
else:
return False
is_even(13)
int main()
{
int a, b;
char c;
cin >> a >> c >> b;
switch (c)
{
case '+':
cout << a + b << endl;
break;
case '-':
cout << a - b << endl;
break;
case '*':
cout << a * b << endl;
break;
case '/':
cout << a / b << endl;
break;
default:
cout << "error" << endl;
}
return 0;
}
sshpass -f <(printf '%s\n' <password>) ssh -o StrictHostKeyChecking=no root@192.168.1.48
echo "my_password" | pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1
exec("pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1", $output, $return);
function sqr(a)
return a * a
function pow(a, b)
if b == 0
return 1
else
return a * pow(a, b - 1)
pow(2, 3)
function add(a, b) {
return a + b;
}
add(1, 2);
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<"Hello World\n";
return 0;
}
const char *cmd = "pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1";
int wstatus;
pid_t pid;
pid = fork();
if (pid == 0) {
execl("/bin/sh", "sh", "-c", cmd, (char *)0);
exit(127); /* only if execv fails */
} else {
waitpid(pid, &wstatus, 0);
if (WIFEXITED(wstatus)) {
printf("exit status %d\n", WEXITSTATUS(wstatus));
}
}
exec_command_with_password("pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1", "password")
#include "curl/curl.h"
#include <curl/easy.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <map>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
using namespace std;
struct string {
char *ptr;
size_t len;
};
void init_string(struct string *s) {
s->len = 0;
s->ptr = (char*) malloc(s->len+1);
if (s->ptr == NULL) {
fprintf(stderr, "malloc() failed\n");
exit(EXIT_FAILURE);
}
s->ptr[0] = '\0';
}
size_t
#include <PGpool.hpp>
#include <PGpool_recovery.hpp>
int main() {
PGpool_recovery pgpool_recovery(std::string("-h 192.168.1.48 -p 9898 -U pgpool -n 1"),std::string("contraseña"));
pgpool_recovery.start();
return 0;
}
int main() {
int a = 0;
int b = 1000;
int c = 0;
int d = 0;
int e = 0;
while(b != 0) {
a = b;
b = c;
c = a%b;
d = d + e;
e = d - e;
d = d - e;
}
return d;
}