[Solved] Low-level read file [closed]

The function you’re looking for is called “read”. You have to pass it a buffer you’ve already allocated previously, however. Something like this ought to work: if (fd) { char buffer[1024]; int n = read(fd, buffer, 1024); /* … */ } after that call, n will contain the number of bytes read from the fd … Read more

[Solved] PHP version unsupported [closed]

I am not sure what scanner you are using, but the PHP versions on both of your servers are no longer supported since 2017. It would be prudent to upgrade the PHP version on both of your servers to at least PHP 7.3 Using old versions is insecure and could lead to hacks and data … Read more

[Solved] Running 3 child processes

Here’s a better instrumented version of your code; it includes the PID in the output, and the outputs are one line each. #include <iostream> #include <cstdlib> #include <sys/wait.h> #include <unistd.h> using namespace std; int main() { int ch1 = fork(); int ch2 = fork(); int ch3 = fork(); if (ch1 == 0) // child1 { … Read more

[Solved] How do I remove all lines starting from the beginning until I reach a certain pattern, except from the last one [closed]

The way to do this is by using awk as you already suggested. As you say, you want to print the lines starting from the first occurrence where you have 3 fields, this can easily be done by setting a print flag (let’s call it p)’ awk ‘(NF==3){p=1};p’ file This will print everything starting from … Read more

[Solved] validating IP in bash, CentOS

Presumably you have some values for regx and presumably you are having some sort of IP list function valid_ip(){ ip=$1 if [[ $ip =~ ^$regx\.$regx\.$regx\.$regx$ ]]; then return 0 else return 1 fi } 0 solved validating IP in bash, CentOS

[Solved] Error in shell script and how to write to a file [closed]

I think this question is fine now, the input file is good enough after edit, I can fully understand what you ask for now. With awk, you need learn to use 2-d array, it will simplify the code. awk ‘BEGIN{print “Instance id Name Owner Cost.centre”} /TAG/{split($0,a,FS);a[4]=tolower(a[4]);$1=$2=$3=$4=””;b[a[3],a[4]]=$0;c[a[3]]} END{for (i in c) printf “%-18s%-26s%-14s%-20s\n”,i,b[i,”name”],b[i,”owner”],b[i,”cost.center”]}’ file Instance id … Read more

[Solved] Linux, BASH launch command with special char [closed]

In order to configure the environment for your subsequent ant command, you have to include the “. ./setantenv.sh” inside your second call. Both calls result in independent bash processes that dont share their specific environment. try this: su – USER -s /bin/bash -c ‘cd /PATH/ && . ./setantenv.sh && ant clean all’ 0 solved Linux, BASH … Read more