I have some resource which I'd like to protect from concurrent usage both by threads in the same process and among different processes.
What is the "right" way of doing it in *nix?
E.g. we want to write to a file from a multithreaded app, which once in a while forks some subprocesses. How to ensure that each thread has exclusive access ...
I'm trying to read binary data in a C program with read() but EOF test doesn't work. Instead it keeps running forever reading the last bit of the file.
#include <stdio.h>
#include <fcntl.h>
int main() {
// writing binary numbers to a file
int fd = open("afile", O_WRONLY | O_CREAT, 0644);
int i;
for (i = 0; i < 10; i++) {
wr...
when I type wget http://yahoo.com:80 on unix shell. Can some one explain me what exactly happens from entering the command to reaching the yahoo server. Thank you very much in advance.
...
I have a data that looks like this:
for_y_axis <-c(0.49534,0.80796,0.93970,0.99998)
for_x_axis <-c(1,2,3,4)
count <-c(0,33,0,4)
What I want to do is to plot the graph using for_x_axis and for_y_axis
but will mark the point with "o" if the count value is equal to 0(zero) and
with "x" if the count value is greater than zero.
Is th...
I would like to implement a virtual filesystem using FUSE under Linux and Mac OS X. I have mainly worked in Java and .NET/C#, but also familiar with Python and do write small utilities/shell scripts in Python. Writing is C/C++ is something that I would try to avoid if possible mainly because of lack of experience in the team.
I see from...
I want to execute a UNIX command from my local Windows XP system using ANT script. UNIX system is a remote server.
I have tried the following:
<target name="execute" >
<sshexec host="host IP"
username="uname"
password="pass"
commandResource="sh abc.sh"/>
</target>
but got the error below:
BUILD FAILED
..\bui...
i have two text files
file 1
number,name,account id,vv,sfee,dac acc,TDID
7000,john,2,0,0,1,6
7001,elen,2,0,0,1,7
7002,sami,2,0,0,1,6
7003,mike,1,0,0,2,1
8001,nike,1,2,4,1,8
8002,paul,2,0,0,2,7
file 2
number,account id,dac acc,TDID
7000,2,1,6
7001,2,1,7
7002,2,1,6
7003,1,2,1
i want to compare those two text files. if the four col...
Hi!
I need to get a username from an Unix path with this format:
/home/users/myusername/project/number/files
I just want "myusername" I've been trying for almost a hour and I'm completely clueless.
Any idea?
Thanks!
...
Hi People,
I found a weird scenario where if I start a java program and I want to exit gracefully with CTRL-C it doesn't work/respond, I have to do a CTRL-Z on the program and this is not cool, doing a ps lists the process... Anyone please.
...
Hi all, when I use the 'date' command, our server gives the GMT time. But my current time should be GMT+8. How do I display my current time as GMT+8? Thanks in advance.
...
I want to make the following kind of reference:
"ls" command, for example, is universally available in most *nix environments. User can type in from anywhere to execute the scripts.
So, I write script "x". I want to make sure that from wherever the user type in x, the actual script "x" is referenced.
Thus, if I have script "x" stored...
Hi,
I have just started using Linux and I am curious how are shell built-in commands such as "cd" defined. Also, if someone could please explain how it is implemented and executed?
Thanks,
Manjari
...
I'm interested in file and raw.
...
I have to search from codebase of lines having following pattern:
"get_token , get_token"
For example the below line 'type' should be listed:
fn1(string.get_token(), string1.get_token());
Thanks in advance
...
Hi!
I have the following problem:
I would like to sort a file on more fields.
A sample tab separated file is:
a 1 1.0
b 2 0.1
c 3 0.3
a 4 0.001
c 5 0.5
a 6 0.01
b 7 0.01
a 8 0.35
b 9 2.3
c 10 0.1
c 11 1.0
b 12 3.1
a 13 2.1
And i would like to have it sorted alphabetically by field 1 (w...
How would i join two lines usung awk or sed?
for eg:
i have data like below:
abcd
joinabcd
efgh
joinefgh
ijkl
joinijkl
i need oupput like below:
joinabcdabcd
joinefghefgh
joinijklijkl
...
What does the number in parentheses after C function name mean in manpages ?
For instance, I see fork(2) and wonder what the 2 means...
Also, I read things like pthread_atfork(3C), so what does the 3C stand for?
...
I am writing an application in C for linux, which uses 2 separate third-party libraries. Both libraries are asynchronous and use select(). They also provide an API which returns the file descriptors they wait on. My intention is to pass these into my own select() and then return control back to whichever library when their own fd values ...
Short background: I need to monitor the permissions on a unix file (a directory) with ZABBIX to see if/when they change. ZABBIX doesn't have any built in like vfs.file.mode[xxxx] for this, so I had to roll my own UserParameter, with a numeric type.
What I do so far, is use ls -l | cut -c 2-10 to get the rwxr-xr-xpart, and then use sed t...
I am trying to install Boost on an unix cluster machine following the Boost instructions
I downloaded boost_1_43_0.tar.bz2 and was then instructed to execute the following command:
tar --bzip2 -xf /path/to/boost_1_43_0.tar.bz2
However it didn't work and this is the output I get:
tar --bzip2 -xf
/path/to/boost_1_43_0.tar.bz2
...