unix

Programming in Unix: Sharing libraries with libraries.

Hi, everyone. Working in C, on top of unix, I am loading and using a shared library somewhat as follows: ... handle = dlopen("nameOfLib"); ... libInit(); ... libGoToState1(); libGoToState2(); .... libTerminate(); ... dlclose(handle); ... What I would like is for my application to admit 'plugins' which take the form of dy...

Delete specific line number(s) from a text file using sed?

I want to delete one or more specific line numbers from a file. How would I do this using sed? ...

Why are my processes in MySQL disappearing for some reason?

When I do: show processlist I see all my 20 servers connected to it. But, after a while, they drop off one by one. I know it's not the script problem. My script does Not terminate. Could it be that it time-out if it doesn't make a query within a certain time? How do I change that setting? Edit: The python script selects and inserts ...

Why POSIX is called "Portable Operating System Interface"?

I have searched hard but still confused why POSIX is called "Portable Operating System Interface", what I learned is that it is some threading library for Unix environment, because when you need to use it under windows you have to use cygwin or "Windows Services of Unix", etc. That's why I am confused why it is called Portable OSIX. I a...

What's a simple way to output homebrewed synthesized sound on Unix?

I want to do some sound synthesis on Mac OS X (and ideally other Unix-like OS) using ANSI C. This is for learning purposes rather than "I need a solution, any solution, quick!" Say I have an 8-bit buffer in my C program that I update 22050 times a second. How can I get my speakers to output that as a waveform? ...

Listing all shared memory segments used by a process on AIX5.3+

I would like to find all shared memory segments used by a given process. I am especially interested in figuring out the shmid so i can use it in calls to shmctl(). On Solaris i would just read /proc/$PID/map to figure out that information (field pr_shmid). The contents of that file are defined by struct prmap_t in sys/procfs. AIX also ...

pthread_exit() and initial thread

When I use pthread_exit() in the initial thread, the initial thread switches in the terminated state. But I did not understand about the process. Can exist a running process with the initial thread in the termitated state? ...

svn problem. I can't add it because it's already in another SVN.

svn add guess_language/ svn: warning: 'guess_language' is already under version control Why is this? When I downloaded it, it was under SVN. (I downloaded it from SVN) How do I release that svn...so that I can turn it into a regular directory? ...

single quotes not working in shell script

I have a .bash_profile script and I can't get the following to work alias lsls='ls -l | sort -n +4' when I type the alias lsls it does the sort but then posts this error message "-bash: +4: command not found" How do I get the alias to work with '+4'? It works when type ls -l | sort -n +4 in the command line I'm in OS X 10.4 Than...

sc_trans metadataPattern

metadataPattern The pattern used to extract metadata from a file name if metadata does not exist or useMetadata == 0. default is /%N. for unix and \%N. for windows %N = song name %G = genre %A = album %R = artist %Y = four digit year %# = sequence of digits %% = % character [] = brackets option...

way to send strings to stdout AND socket in 1 line

I want to write this to only 1 line: fprintf(stdout, "RCPT TO: <%s>\r\n", argv[argc-1]); fprintf(sockfd, "RCPT TO: <%s>\r\n", argv[argc-1]); so i want to send the same string to stdout and to my open socket. How can I do this? ...

How to remove part of filename and add extension programmatically?

I have hundreds of files in one folder named like this: index.html?tab=This is - the file name I would like to remove "index.html?tab=" part and add extension ".txt" to all files. How can I do this using Unix command line tools (I'm using MacOSX 10.6.2)? ...

DB load CSV into multiple tables

UPDATE: added an example to clarify the format of the data. Considering a CSV with each line formatted like this: tbl1.col1,tbl1.col2,tbl1.col3,tbl1.col4,tbl1.col5,[tbl2.col1:tbl2.col2]+ where [tbl2.col1:tbl2.col2]+ means that there could be any number of these pairs repeated ex: tbl1.col1,tbl1.col2,tbl1.col3,tbl1.col4,tbl1.col5,tb...

find all subversion working copies on machine

How could I use find unix utility to find all working copies on the machine? For example, I can use find / -name .svn -type d command, but it outputs all redundant results (a lot of subfolders), while I need only parent directory of working copy to be shown. There is related question, but it does not really help in my case: http://stac...

Ruby system('ls') to string?

How could I have the output of say the unix 'ls' (Desktop, Pictures, Music myysong.mp3 etc) be converted to a string?? thx in advance ...

Automatically download log file from Unix server to Windows machine.

I have a Unix server on which a continuously running application generates a large text log. (aprox. 100megs an hour). My main development machine is a Windows computer and to see what's going on with the application I use Filezilla to download the log file to the PC where I use notepad++ to go thru log entries. The whole process seem...

How to correctly save the unix top command output into a variable?

I've got to save the output of the top command into a variable and I do this: myvar=`top -b -n1 | head -n 18` The problem is that it seems to be ignoring the return characters, so when I echo the content of $myvar I see something like: top - 15:15:38 up 745 days, 15:08, 5 users, load average: 0.22, 0.27, 0.32 Tasks: 133 total, 1 runn...

What should expericenced Unix programmer to be aware of using Microsoft Tools?

I come from UNIX world, I'm quite familiar with Linux, Solaris, Cygwin and MinGW development. Recently I ported one of my big projects (cppcms) to support MSVC, including building static and dynamic libraries with CMake. And I get all the time absolutely weird issues: I had CMake build issues because Windows programming lacks namin...

How to get return value from CHILD PROCESS?

Program calculates sum of numbers from 1 to N.. Child process calculates sum of EVEN numbers. Parent process calculates sum of odd numbers. I want to get the return value of child process in parent process. How do i do that #include<stdio.h> #include<errno.h> #include<unistd.h> #include<stdlib.h> #include<fcntl.h> int main() { int ...

/bin/sh: How to redirect from &3 to named pipe?

I have a background process read from named pipe. for example mkfifo /tmp/log.pipe ./myprog.sh < /tmp/log.pipe I want to use &3 instead of specify /tmp/log.pipe echo "aaa" >&3 but results similar to echo "aaa" > /tmp/log.pipe How can I redirect &3 to /tmp/log.pipe everytime. ...