unix

How to get a pointer to the beginning of a file in C++

Hi Is it possible in C++ to somehow get a pointer to the beginning of an opened file so that it ( the pointer ) can be passed to the unix write function together with the size of the file? Just to be clear: I want to pass the whole file to a write-like function - how do I do this? ...

Emailing about IP changes

You can choose any language. I am interested to know the simplest solution. How can you get your comp's IP and email it? ...

*nix select and exceptfds/errorfds semantics

The select() syscall takes 3 filedescriptor sets for watching fds for readable/writeable and "exceptions" on filedescriptor. My select man page doesn't state much about the exceptfd descriptor set. What is it used for - what kind of exceptions can and will it notify on file descriptors ? I'm assuming this can be different for the descr...

mkfifo file permissions not being executed correctly

The following line in my C program should provided All/Group/Owner read and write permissions mkfifo("/tmp/dumbPipe", 0666) But once I execute the code and check out the permission non of the write bits were set, I end up with prw-r--r-- The owners are the same, Is it a problem since I'm creating the pipe in the tmp directory? When...

Get CPU and memory usage of application programatically on HPUX

Is there a way to get the CPU and memory usage programatically (C++) of an application on HPUX? ...

Is there a Unix command to echo out an entire dictionary?

I'm writing a program that uses regular expressions to make comparisons against the entire dictionary on the UNIX shell. Is there a way that I can echo some sort of predefined dictionary and then pipe it to grep? I was thinking I could use the backend of some programs spell-checker? Or do I just need to echo a file of words? If so, whe...

Why sockaddr_storage structure defined as the way it is defined?

Below is the definition of sockaddr_storage structure (rfc2553). According rfc2553, the sockaddr_storage should be aligned with 64 bit boundary and it should be able to hold both sockaddr_in and sockaddr_in6. Also, it must have atlest __ss_family member. Rest of the fields are implementation defined. #define _SS_MAXSIZE 128 /* Imple...

Applications of fork system call

fork is used to create a copy of process from which its called. This is typically followed by calls to exec family of functions. Are there any usages of fork other than this? I can think of one. Doing IPC with pipe functions. ...

Unable to untar a file?

I have written a shellscript which tries to pull a tar file from an ftp server and untar it locally. I need to extract specific files from the tar archive. The filename of the tarfile contains a date; I need to be able to select a tar file based on this date. abc_myfile_$date.tar is the format of the file I am pulling from the ftp serve...

System processes in Unix

One book on Unix programming says The init process never dies. It is a normal user process, not a system process within the kernel, like the swapper, although it does run with superuser privileges. What makes a process a system process? Is the system process embedded within the kernel code? Do all system processes run with superu...

To restrict a node from `tree` by Tree or Git

How can you restrict a node from the command tree? #1 I need to give a tree of my project files reqularly for my supervisor. These files contain some third-party components which I do not want to show in the tree. I have solved this problem this far by coping the project file to tmp, removing 3rd party-files and then running tree. How...

Summing up two columns the Unix way

# To fix the symptom How can you sum up the following columns effectively? Column 1 1 3 3 ... Column 2 2323 343 232 ... This should give me Expected result 2324 346 235 ... I have the columns in two files. # Initial situation I use sometimes too many curly brackets such that I have used one more this { than this } in my f...

How do I split a large file in unix repeatedly?

I have a situation with a failing LaCie 500GB hard drive. It stays on for only about 10 minutes, then becomes unusable. For those 10 minutes or so I do have complete control. I can't get my main mov file(160GB) transferred off that quickly, so I was thinking if I split it into small chunks, I could move them all off. I tried splitting t...

problem with using wildcards in case statement in unix?

in localpath i have files with names myfile1_20090821.dat myfile2_20090831.dat myfile3_20090811.dat myfile4_20090822.dat myfile5_20090825.dat type="OP" module="abc" if [ $type == 'OP' ]; then case $module in abc) x=1 while [ $x -le 5 ] do INPUT_FILE[$x]=`ls localpath/myfile$x*.dat` x=$(( $x + 1 )) done;; *) echo...

Get instruction pointer of running application on Unix

Is there a way to get the instruction pointer of a running application Unix? I have a running process (C++) and want to get its current location, and thereafter in GDB (on a different machine) map the location to source location ('list' command). ...

Multiple grep search/ignore patterns

I usually use the following pipeline to grep for a particular search string and yet ignore certain other patterns: grep -Ri 64 src/install/ | grep -v \.svn | grep -v "file"| grep -v "2\.5" | grep -v "2\.6" Can this be achieved in a succinct manner? I am using GNU grep 2.5.3. ...

bash: Measure disk space of certain file types in aggregate

I have some files across several folders: /home/d/folder1/a.txt /home/d/folder1/b.txt /home/d/folder1/c.mov /home/d/folder2/a.txt /home/d/folder2/d.mov /home/d/folder2/folder3/f.txt How can I measure the grand total amount of disk space taken up by all the .txt files in /home/d/? I know du will give me the total space of a given fold...

Any risks using Macports?

I'm considering installing macports on my mac so I can have easy access to *nix dev tools/apps. However, I'm wondering if there are any risks. I'm ok with the inevitable compatibility issue from time to time (hear snow leopard + macports has issues) but I do not want the stability of my "core" mac system to be effected. I'm also curio...

Listing the latest file/folder using wget

I wish to get a particular set of files and the only access I have on that box is through the http inteface, which I can get from wget. Now the issue is that I want the latest files, and there are multiple which must be of the same time stamp. wget http://myserver/abc_20090901.tgz wget http://myserver/xyz_20090901.tgz wget http://myserv...

Migrating to open systems

I'm a windows (C++/.NET) developer. I want to migrate to UNIX systems because I'm tired of windows shit. Endless MS stupid silly buggy SDKs kill me every day and I'm not really enjoying programming like it was before. My question is what is the possible roadmap. Any chance to find a job in UNIX area with over 8 years of windows-only exp...