Dnes je to 10 let, co byla vytvořena decentralizovaná kryptoměna Dogecoin. Autoři Billy Markus a Jackson Palmer ji původně zamýšleli jako vtip. Znakem kryptoměny je pes Shiba-Inu známý z internetových memů.
Google Chrome 120 byl prohlášen za stabilní. Nejnovější stabilní verze 120.0.6099.62 přináší řadu oprav a vylepšení (YouTube). Opraveno bylo 10 bezpečnostních chyb. Vylepšeny byly také nástroje pro vývojáře (YouTube).
Byla vydána nová verze 2023.4 linuxové distribuce navržené pro digitální forenzní analýzu a penetrační testování Kali Linux (Wikipedie). Přehled novinek se seznamem nových nástrojů v oficiálním oznámení. Vypíchnout lze podporu Cloud ARM64, Vagrant Hyper-V a Raspberry Pi 5.
Společnosti IBM, Meta a dalších vice než 50 zakládajících členů (bez Microsoftu a OpenAI) vytvořili mezinárodní alianci AI Alliance pro spolupráci na vývoji a rozvoji otevřené, bezpečné a odpovědné umělé inteligence.
Služba pro hlídání uniklých hesel Have I Been Pwned oslavila 10. výročí. Troy Hunt ji spustil 4. prosince 2013 (Twitter).
Programovací jazyk HTML.
Podpora TORu v Debianu 11 Bullseye a 10 Buster byla ukončena. Doporučuje se přechod na Debian 12 Bookworm.
Příkaz "opakuj donekonečna" je nově v rozporu s podmínkami používání ChatGPT. Příkaz vedl k prozrazení trénovacích dat [/.].
GNU Project Debugger aneb GDB byl vydán ve verzi 14.1. Podrobný přehled novinek v souboru NEWS. Vypíchnout lze podporu NO_COLOR a Debugger Adapter Protocol (DAP).
Byla vydána verze 5.0 webového aplikačního frameworku napsaného v Pythonu Django (Wikipedie). Přehled novinek v poznámkách k vydání.
|v C. Kod nize funguje jako rourapro prikazy bez parametru, ale premyslim, jak to udelat, aby roura fungovala obecne, tj. zpracovavala by jako argumenty shellovske prikazy i s jejich pripadnymi parametry. Kod nize spousti shellovsky prikaz
prikaz1 | prikaz2 dvajako
./pipe prikaz1 prikaz 2a ja bych chtel aby to fungovalo napriklad jako:
./pipe prikaz1 -abcde prikaz2 -a -b -cNapadaji me jenom same drsne zpusoby jak to vyresit, pomoci ruzneho parsovani, ale tim by se kod stal prilis robustni
int main(int argc,char **argv) { int fd[2]; pipe(fd); pid_t childpid; pid_t pid = fork(); if (childpid == -1) { perror("Error forking..."); exit(1); } if (pid == -1) return -1; if (pid == 0) { close(fd[1]); //close write to pipe, in child dup2(fd[0], STDIN_FILENO); // Replace stdin with the read end of the pipe close(fd[0]); // Don't need another copy of the pipe read end hanging about execlp(argv[2],argv[2],argv[3],NULL); } else { close(fd[0]); //close read from pipe, in parent dup2(fd[1], STDOUT_FILENO); // Replace stdout with the write end of the pipe close(fd[1]); // Don't need another copy of the pipe write end hanging about execlp(argv[1],argv[1],NULL); } return EXIT_SUCCESS; }
Řešení dotazu:
./pipe command1 -s -tisicem param etru %DELIMITER% command2 -s -jinym --tisicem par ametru
cat test
a druhý xargs file
, nedokážete určit, kde to správně rozdělit (záměrně jsem vybral taková jména, kde každé slovo je zároveň i jméno existujícího programu).
Nejjednodušší řešení je to zauvozovkovat, tedy aby se ten program i s parametry předával jako jeden parametr, a místo execlp
použít system
:
./pipe "prikaz1 -abcde" "prikaz2 -a -b -c"
@Vysledny kod vypada takto:
int main(int argc,char *argv[]) { if (argc < 2) { printf("Programme must be run with with arguments and using pipe shell symbol as a delimiter!\n" "For example: ./pipe ls -la @ grep -v .c\n"); exit(1); } int count; int fd[2]; char command1[50]; char command2[50]; char arguments1[50]; char arguments2[50]; strcpy(command1, argv[1]); strcpy(arguments1, " "); strcpy(arguments2, " "); count = 2; for (; count < argc; count++) { if (strcmp(argv[count], "@") == 0) { break; } strcat(arguments1, argv[count]); strcat(arguments1, " "); } arguments1[strlen(arguments1)-1] = '\0'; //removing ending space strcat(command1, arguments1); strcpy(command2, argv[count+1]); count += 2; for ( ; count < argc; count++) { strcat(arguments2, argv[count]); strcat(arguments2, " "); } arguments1[strlen(arguments2)-1] = '\0'; strcat(command2, arguments2); pipe(fd); pid_t pid = fork(); if (pid == -1) return -1; if (pid == 0) { close(fd[1]); //close write to pipe, in child dup2(fd[0], STDIN_FILENO); // Replace stdin with the read end of the pipe close(fd[0]); // Don't need another copy of the pipe read end hanging about system(command2); } else { close(fd[0]); //close read from pipe, in parent dup2(fd[1], STDOUT_FILENO); // Replace stdout with the write end of the pipe close(fd[1]); // Don't need another copy of the pipe write end hanging about; system(command1); } return EXIT_SUCCESS; }
mkfifo()?
fopen: No such file or directoryDOsavadni kod:
int main(int argc,char *argv[]) { if (argc < 2) { printf("Programme must be run with with arguments and using pipe shell symbol as a delimiter!\n" "For example: ./pipe ls -la @ grep -v .c\n"); exit(1); } int count, fw, fr; char command1[50]; char command2[50]; char arguments1[50]; char arguments2[50]; strcpy(command1, argv[1]); strcpy(arguments1, " "); strcpy(arguments2, " "); count = 2; for (; count < argc; count++) { if (strcmp(argv[count], "@") == 0) { break; } strcat(arguments1, argv[count]); strcat(arguments1, " "); } arguments1[strlen(arguments1)-1] = '\0'; //removing ending space strcat(command1, arguments1); strcpy(command2, argv[count+1]); count += 2; for ( ; count < argc; count++) { strcat(arguments2, argv[count]); strcat(arguments2, " "); } arguments1[strlen(arguments2)-1] = '\0'; strcat(command2, arguments2); mkfifo(FIFO_FILE, S_IFIFO|0666); pid_t pid = fork(); if (pid == -1) return -1; if (pid == 0) { //close(fifo); //close write to pipe, in child //dup2(fifo, STDIN_FILENO); // Replace stdin with the read end of the pipe //close(fifo); // Don't need another copy of the pipe read end hanging about if(fr = fopen(FIFO_FILE, "r") == NULL) { perror("fopen"); exit(1); } dup2(fr, STDIN_FILENO); close(fr); system(command2); } else { //close(fifo); //close read from pipe, in parent //dup2(fifo, STDOUT_FILENO); // Replace stdout with the write end of the pipe //close(fifo); // Don't need another copy of the pipe write end hanging about; if(fw = fopen(FIFO_FILE, "w") == NULL) { perror("fopen"); exit(1); } dup2(fw, STDOUT_FILENO); close(fw); system(command1); } return EXIT_SUCCESS; }
Tiskni
Sdílej: