unix

What is the difference between AF_INET and PF_INET constants?

Looking at examples about socket programming, we can see that some people use AF_INET while others use PF_INET. In addition, sometimes both of them are used at the same example. The question is: Is there any difference between them? Which one should we use? If you can answer that, another question would be... Why there are these two sim...

Getting environment from .profile while executing a command through ssh

Hi, I am new to the linux/unix world. I would like to trigger a make on a remote machine. For this purpose i created a little script on the remote machine which i want to execute via ssh. The script looks something like this: echo "loading .profile" . ~/.profile echo "profile loaded" echo "starting gmake" cd ~/helloWorld/ gmake all ...

Oracle PL/SQL: Dump query result into file

Hi. I'm working on a pl sql stored procedure. What I need is to do a select, use a cursor and for every record build a string using values. At the end I need to write this into a file. I try to use dbms_output.put_line("toto") but the buffer size is to small because I have about 14 millions lines. I call my procedure from a unix ksh. I...

cat file | ... vs ... <file

Is there a case of ... or context where cat file | ... behaves differently than ... <file? ...

Why does the rename() syscall prohibit moving a directory that I can't write to a different directory?

I am trying to understand why this design decision was made with the rename() syscall in 4.2BSD. There's nothing I'm trying to solve here, just understand the rationale for the behavior itself. 4.2BSD saw the introduction of the rename() syscall for the purpose of allowing atomic renames/moves of files. From 4.3BSD-Reno/src/sys/ufs/uf...

unix at command pass variable to shell script?

Hi, I'm trying to setup a simple timer that gets started from a Rails Application. This timer should wait out its duration and then start a shell script that will start up ./script/runner and complete the initial request. I need script/runner because I need access to ActiveRecord. Here's my test lines in Rails output = `at #{(Time.n...

Convert Memory Size (Human readable) into Actual Number (bytes) in Perl

Is there an actual package in CPAN to convert such string: my $string = "54.4M" my $string2 = "3.2G" into the actual number in bytes: 54,400,000 3,200,000,000 And vice versa. In principle what I want to do at the end is to sum out all the memory size. ...

Convert Chunk of Data into Tabular Format Using Perl

I have a data that looks like this 1:SRX000566 Submitter: WoldLab Study: RNASeq expression profiling for ENCODE project(SRP000228) Sample: Human cell line GM12878(SRS000567) Instrument: Solexa 1G Genome Analyzer Total: 4 runs, 62.7M spots, 2.1G bases Run #1: SRR002055, 11373440 spots, 375323520 bases Run #2: SRR002063, 22995209 spots, 7...

Build Systems for PHP Web Apps

I want to start automating more of my web development process so I'm looking for a build system. I write mostly PHP apps on Mac OS X and deploy Linux servers over FTP. A lot of my clients have basic hosting providers so shell access to their servers is typically not available, however remote MySQL access is usually present. Here is what ...

Unable to understand read() system call

There is a simple Client-Server program. The server is started $./server 5000 The client is also connected to server.. $./client 127.0.0.1 5000 The client enters a string Client has the message "I got your message" displayed on his terminal & server displays the entered string by the client The issue is that when I run client by doi...

Monotonic clock on IRIX

I want to get a monotonic clock on IRIX, like: clock_gettime(CLOCK_MONOTONIC, &t); But CLOCK_MONOTONIC doesn't exist on IRIX. It has CLOCK_SGI_CYCLE, but that (as the names says) cycles too often (about every 90s on my machine in case you're interested). Is there any other (fairly high-res) clock that I can use, that isn't affected ...

Why is this not a bug in qmail?

I was reading DJB's "Some thoughts on security after ten years of Qmail 1.0" and he listed this function for moving a file descriptor: int fd_move(to,from) int to; int from; { if (to == from) return 0; if (fd_copy(to,from) == -1) return -1; close(from); return 0; } It occurred to me that this code does not check the return va...

change permissions in C by using exec()

How can I implement chmod command on file by using exec? I would appreciate if anyone can provide me a code. ...

Efficient copy of entire directory

I want to copy one directory and the two files under it to another shared location of shared storage. Is it possible to combine the three(one directory and two files) as a continuous file writing and decompose it at another side to save the cost? I am limited to c language and Unix/Linux. I am considering to create a structure with the i...

I was doing some moving around in SVN, and copying files back and forth. Now I can't use it.

I deleted files in my SVN, and dragged new files into it over WINSCP. Now, I try to add all the files and commit, but it won't let me. $ svn add * svn: '.' is not a working copy svn: Can't open file '.svn/entries': No such file or directory ...

Hudson trigger builds remotely gives a forbidden 403 error

I have a shell script on the same machine that hudson is deployed on and upon executing it, it calls wget on a hudson build trigger URL. Since its the same machine, I access it as http://localhost:8080/hudson/job/jobname/build?token=sometoken Typically, this is supposed to trigger a build on the project. But I get a 403 forbidden when I...

Is there a way to close a Unix socket for only reading or writing?

Is there a way to only close "one end" of a TCP socket to cleanly indicate one side of a connection is done writing to the connection? (Just like you do with a pipe in every Unix pipe tutorial ever.) Or should I use some in-band solution like a sentinel value or some such? ...

Someone please help google create instuctions that windows users understand. googles "instructions" for the Android NDK install.

Below are the only instructions i managed to find from google on how to install the android NDK, it is written as if we all run Linux and presumes we all understand what these obscure tools are. My comments and questions appear in Italics if somone who knows unix and windows would translate for google that would be great! Android NDK ...

C Allocating Two Dimensional Arrays

I am trying to allocate a 2D dimension array of File Descriptors... So I would need something like this fd[0][0] fd[0][1] I have coded so far: void allocateMemory(int row, int col, int ***myPipes){ int i = 0,i2 = 0; myPipes = (int**)malloc(row * sizeof(int*)); for(i = 0; i < row;i++){ myPipes[i] = (int*)ma...

Crontab sets 18:00 to 09:00

I just want to set a crontab using that I want to make a program run at every 15 minutes from 18:00 to 09:00 I have given this statement and waited but I don't think it is working */15 18-9 * * 1-6 Program_name Any suggestion would be greatly appreciated ...