Jose Velasquez

All generations.

generate functionSat, 17 Jun 2023

enviar contraseña a pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

#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] =

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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; }

C++
View
generate functionTue, 25 Apr 2023

programa en c++ que haga un pin a un servidor linux y escriba en un archivo de texto el estatus

#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; }

C++
View
generate functionSat, 17 Jun 2023

enviar contraseña y escribirla automaticamente en el prompt de linux

#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; }

C++
View
generate functionSun, 18 Jun 2023

script linux ejecutar comando y password

# 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; }

generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 y enviar la contraseña

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

C++
View
generate functionSun, 18 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 sin contraseña

#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; }

C++
View
generate functionSun, 18 Jun 2023

ejecutar un programa y leer la contraseña de un archivo linux

#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; }

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 y enviar la contraseña

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

C++
View
generate functionSun, 18 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 con contraseña

#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

generate functionTue, 25 Apr 2023

escribe un programa que haga pin a un servidor en linux y diga si esta arriba o no

#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

C++
View
generate functionSun, 18 Jun 2023

programa que escriba la contraseña solicitada por otro programa

#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; }

C++
View
generate functionSun, 18 Jun 2023

pcp_recovery_node -h 198.168.1.48 -p 9898 -U pgpool -n 1 -w no funciona

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

C++
View
generate functionSun, 18 Jun 2023

como escribir automaticamente la contraseña solicitada por un programa linux

#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; }

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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; }

C++
View
generate functionSun, 18 Jun 2023

script linux ejecutar comando y password

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

generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 con contraseña

#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);

C++
View
generate functionSun, 18 Jun 2023

ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 y colocarle la contraseña en el la terminal

#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

C++
View
generate functionSun, 18 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 sin contraseña

#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

generate functionSun, 18 Jun 2023

script linux ejecutar comando y password

++ #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

generate functionSat, 17 Jun 2023

enviar contraseña a pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

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; }

C++
View
generate functionSat, 17 Jun 2023

un comando y su contraseña

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; }

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 con contraseña

#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; }

C++
View
generate functionSat, 17 Jun 2023

escribir contraseña en el prompt de linux

#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; }

C++
View
generate functionTue, 28 Mar 2023

una función que calcule la ecuación de segundo grado

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"; } }

C++
View
generate functionSat, 17 Jun 2023

ejecutar un programa y enviarle la contraseña que pedira

#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) {

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 con contraseña

#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

C++
View
generate functionSun, 18 Jun 2023

programa que ejecute recovery_node pgpool 4.2.4

#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

C++
View
generate functionSun, 18 Jun 2023

programa que escriba la contraseña solicitada en el prompt

#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; }

C++
View
generate functionSun, 18 Jun 2023

programa que ejecute un ping y tome deciciones

#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

C++
View
generate functionSun, 18 Jun 2023

programa que escriba la contraseña solicitada por otro programa en linux

#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;

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

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());

C++
View
generate functionWed, 26 Apr 2023

programa en c++ que resuelva la ecuación de segundo grado

#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

C++
View
generate functionWed, 29 Mar 2023

escribe un programa que lea cuatro números y determine y determine cual de ellos es el mayor

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; }

C++
View
generate functionSat, 17 Jun 2023

enviar contraseña y escribirla automaticamente en el prompt de linux

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()

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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 ");

C++
View
generate functionSun, 18 Jun 2023

ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 y colocarle la contraseña en el la terminal

// 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; }

C++
View
generate functionSun, 18 Jun 2023

pgpool 4.2.4 recovery_node

/* * 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))); } }

C++
View
generate functionTue, 25 Apr 2023

escribe un programa que haga pin a un servidor en linux y escriba en un archivo de texto el estus del servidor

#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);

C++
View
generate functionSat, 17 Jun 2023

enviar contraseña a pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

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) }

C++
View
generate functionTue, 25 Apr 2023

escribe un programa que haga pin a un servidor en linux

#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,

C++
View
generate functionWed, 29 Mar 2023

escribe un programa que lea cuatro números y determine y determine cual de ellos es el mayor

#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

C++
View
generate functionSat, 17 Jun 2023

ejemplo de como ejecutar pcp_recovery_node de pgpool-II

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

C++
View
generate functionSun, 18 Jun 2023

ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 y colocarle la contraseña en el la terminal

#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; }

C++
View
generate functionSun, 18 Jun 2023

pgpool 4.2.4 recovery_node

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. */

C++
View
generate functionSat, 17 Jun 2023

ejecutar un programa con su contraseña a la vez

#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; }

C++
View
generate functionSat, 17 Jun 2023

enviar contraseña a pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

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); }

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 con contraseña

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);

C++
View
generate functionTue, 25 Apr 2023

escribe un programa que haga pin a un servidor en linux y diga si esta arriba

# 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_

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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);

C++
View
generate functionSun, 18 Jun 2023

pgpool 4.2.4 recovery_node

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

C++
View
generate functionSun, 18 Jun 2023

programa que haga un ping y diga hola si el pin funciona

#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); }

C++
View
generate functionTue, 25 Apr 2023

escribe un programa si linux esta funcionando

#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."); }

C++
View
generate functionSat, 17 Jun 2023

enviar contraseña a pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1

#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

C++
View
generate functionSat, 17 Jun 2023

como ejecutar pcp_recovery_node -h 192.168.1.48 -p 9898 -U pgpool -n 1 sin contraseña

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); }

C++
View
generate functionSun, 18 Jun 2023

pcp_recovery_node -h 198.168.1.48 -p 9898 -U pgpool -n 1 -w no funciona

#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

C++
View

Questions about programming?Chat with your personal AI assistant