unix

How to scale a TCP listener on modern multicore/multisocket machines....

I have a daemon to write in C, that will need to handle 20-150K TCP connections simultaneously. They are long running connections, and rarely ever tear down. They have a very small amount of data (rarely exceeding MTU even.. it's a stimulus/response protocol) in transmit at any given time, but response times to them are critical. I'm ...

Kill the process using its name inside linux (Python)

Hello, this works, but it kills every Python process. pkill python However, I cannot do: pkill myscript.py I have also tried killall, but with no luck either. Do I have to user regular expressions? By the way, I want to do this in a python script with import os. ...

How do I split up a line and rearrange its elements?

I have some data on a single line like below abc edf xyz rfg yeg udh I want to present the data as below abc xyz yeg edf rfg udh so that alternate fields are printed with newline separated. Are there any one liners for this? ...

Remove empty new lines in a text file via grep

FILE: hello world foo bar How can when remove all the empty new lines in this FILE? Output of command: FILE: hello world foo bar ...

Python Pipes - What Happens When Reading Output Incrementally

According to a section in this presumably accurate book, A common use of pipes is to read a compressed file incrementally; that is, without uncompressing the whole thing at once. The following function takes the name of a compressed file as a parameter and returns a pipe that uses gunzip to decompress the contents: de...

Why does the Windows registry exist?

Hi, this is more OS architecture question than programming directly, but still. Why was the Windows registry created as a completely separate subsystem for storing system/application settings? In *nix OS'es there is /etc directory which is perfectly understandable, as filesystem is a natural hierarchical way for storing settings, while...

cat file with no line wrap

In *nix, how do I display (cat) a file with no line-wrapping: longer lines should be cut such that they fit into screen's width. ...

Surround all lines in a text file with quotes ('something')

I've got a list of directories that contain spaces. I need to surround them with ' ' to ensure that my batch scripts will work. How can one surround each new line with a ' and a ' (quotes). e.g. File1: /home/user/some type of file with spaces /home/user/another type of file with spaces To File2: '/home/user/some type of file wit...

Replace two or more spaces within a text file with a ;

File1: hello world foo bar a word with a space I need to replace all white spaces which are two or more in length with a semi-colon(;). Result: File2: hello;world foo;bar a;word with a space ...

In a *nix shell, how can I connect to another server's FTP and download a file?

On server1, I have a file in /home/example.zip. On server2, I need to basically do the equivalent of: wget http://server1.com/example.zip But of course via ftp. I of course have the username/password/host name. How can this be achieved? ...

How to move to development after working on support projects for three+ years ?

I am working on support projects from last 3 years on unix environments. Where I didn't get much exposure to development work. Though I got good experience to solving critical problems and debugging code for finding the defects but not much to develop. I am performing good at work but sometimes I feel very low. What my question to all gr...

How can I search for 3 strings at a time in the vi editor?

How can I search for 3 strings at a time in the vi editor? I was wondering how could we do it. I.e. search for 3 strings at a time in vi like I do: :/xyz in command mode. How could I add 2 more strings so that the cursor will stop at a string which ever is found first among the three and if we press n it will stop at the string that i...

How to replace new lines with tab characters

hi i have pattern like below hi hello hallo greetings salutations no more hello for you i am trying to replace all new lines with tab spaces using the following command sed -e "s_/\n_/\t_g" but its not working . could nybody pls help? i need the solution in sed /awk. ...

Splitting string into array

I want to split the string and construct the array. I tried the below code: myString="first column:second column:third column" set -A myArray `echo $myString | awk 'BEGIN{FS=":"}{for (i=1; i<=NF; i++) print $i}'` # Following is just to make sure that array is constructed properly i=0 while [ $i -lt ${#myArray[@]} ] do echo "Element $i:$...

Is there a standard way to convert a struct timeval into a struct timespec?

struct timeval represents and instant in time with two members, tv_sec (seconds) and tv_usec (microseconds). In this representation, tv_usec is not by itself an absolute time it is a sub second offset off of tv_sec. struct timespec works the same way except that instead of microseconds it's offset (tv_nsec) is stored in nanosecond units...

Any lightweight *nix environment for programming

Is there any lightweight *nix OS dedicated for programming purposes? Actually, I have a full installation of Mandriva in my computer; but sometimes in Windows I must use Virtualbox to run some *nix OS. Because I only need the OS for only programming in this case, so I just want to ask you about it. Of course, I searched about this on ...

How feasible would it be to create a bash shell in a browser?

Primarily, I'm a C/C++ programmer on Unix machines... But I'd kill for browser based shell access to a linux box... So, the question is: How hard would it be, and what approaches would be the best for building real shell level access into a web page? Flash? Javascript? I know this is really all opinion, but I'm curious if people think ...

Inline SED regular expression question

I work for a company that offers webhosting and DNS services. We are trying to migrate everything over to new servers and we've often run into stale zonefiles on our servers as customers have changed their authoritative servers to someone else. I am trying to write a script that will check whois, ns, and SOA information to determine if...

How can I set the time zone before calling strftime?

I represent dates using seconds (and microseconds) since 1970 as well as a time zone and dst flag. I want to print a representation of the date using strftime, but it uses the global value for timezone (extern long int timezone) that is picked up from the environment. How can I get strftime to print the zone of my choice? ...

How to include .htaccess in tar commands?

hi, whenever i do tar -pczf file.tar.gz * it ignores any .htaccess files, and i can't see in the man how to include it. any ideas? thanks ...