[Solved] C read file in byte chunks [closed]

Well if you can’t use man, why not just search for it? Anyway you are using it wrong. If you want to read it by chunks you should do it like this // consider that we allocated enough memory for buffer // and buffer is byte array ssize_t r = 0, i = 0; do … Read more

[Solved] Understanding an exercise in K&R [closed]

The while loop continues to execute as long as it gets a character from stdin that is not EOF: while((c = getchar()) != EOF) Two char variables are declared: c and lastc. For this logic to work, the current character and the previous character must be known. Initially, lastc does not have a value, but … Read more

[Solved] How to perform cache operations in C++?

You have no need to flush the cache from your user-mode (non-kernel-mode) program. The OS (Linux, in the case of ubuntu) provides your application with a fresh virtual address space, with no “leftover stuff” from other programs. Without executing special OS system calls, your program can’t even get to memory that’s used for other applications. … Read more

[Solved] how do I basic script with linux? [closed]

#!/bin/bash is called the shebang (you missed the leading #). It tells which program will execute your script. clear is for clearing screen. echo outputs following argument to the standard output (your terminal by default). But you must not surround your string with parenthesis as it’s used for grouping command in a sub-shell. If you … Read more

[Solved] C program with functionality as cp command

The open() system call returns a file descriptor, which may not be 1, so your termination condition, while(infile==1){ is compeletely bogus. You should test if the read() call read any input (the return value is the number of bytes read, which is zero when it hit end-of-file.) Please read the read man page… pun intended … Read more

[Solved] Create directory structure in unix [closed]

current_year=$(date +%Y) next_month=$(($(date +%m) + 1)) locale_next_month=$(date -d$current_year/$next_month/1 +%B) for day_of_month in $(seq 1 31) do if day_of_year=$(date -d$current_year/$next_month/$day_of_month +%j 2> /dev/null) then mkdir -p /home/applications/app_name/$current_year/$locale_next_month/$day_of_year fi done 1 solved Create directory structure in unix [closed]

[Solved] Perl Script can’t use Tie::File

Introduction Perl is a powerful scripting language that is used for a variety of tasks, including web development, system administration, and data manipulation. One of the most useful features of Perl is its ability to tie files together using the Tie::File module. This module allows you to access and manipulate data stored in a file … Read more

[Solved] Perl Script can’t use Tie::File

Your program is frankly a bit of a mess. You seem to be trying things in the hope that they work but without any real reasoning. I have refactored your code to do what I think you want below. Here are the main changes I have made You must always add use strict and use … Read more

[Solved] python IndentationError: expected an indented block [closed]

You have no indentation in your Python code! def datasource(cluster,user,password,url,env,jdbc_driver,timeOut,maxConn,minConn,reapTime,unusdTimeout,agedTimeout): #Declare global variables global AdminConfig global AdminControl Fixing this, there will be others. The next one to fix is: if len(Serverid) == 0: print “Cluster doesnot exists ” else: print “Cluster exist:”+ cluster and so on. 1 solved python IndentationError: expected an indented block [closed]

[Solved] Shell Script – Adding memory functionality

You should store the result in a variable like this: result=$((operand1+operand2)) Then your first if statement can check if this variable has a value, and if it does, skip the read and use it instead. if [[ $result == “” ]]; then echo Enter operand1 value: read operand1 else operand1=$result echo “Operand 1 is: $result” … Read more

[Solved] awk : parse and write to another file

Use GNU awk for multi-char RS: $ awk -v RS='</record>\n’ ‘{ORS=RT} /<keyword>SEARCH<\/keyword>/’ file <record category=”xyz”> <person ssn=”” e-i=”E”> <title xsi:nil=”true”/> <position xsi:nil=”true”/> <names> <first_name/> <last_name></last_name> <aliases> <alias>CDP</alias> </aliases> <keywords> <keyword xsi:nil=”true”/> <keyword>SEARCH</keyword> </keywords> <external_sources> <uri>http://www.google.com</uri> <detail>SEARCH is present in abc for xyz reason</detail> </external_sources> </details> </record> If you need to search for any of multiple … Read more

[Solved] Unix Command | ps [closed]

Copied from man ps: -u userlist Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist. The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)). Identical to U and –user. Meaning: it prints all the … Read more