linux

Understanding behaviour of read() and write()

hi i am a student and just start learning low level c programming.i tried to understand read() and write() methods with this program. #include <unistd.h> #include <stdlib.h> main() { char *st; st=calloc(sizeof(char),2);//allocate memory for 2 char read(0,st,2); write(1,st,2); } i was expecting that it would give segmen...

Killing a process

I have a for loop to get the list of PID's and kill each PID. I want to display the entire line of PS output and write it to the /tmp/outfile . But from each line of PS output each field(PID,PPID,...) is written along with a new line in the /tmp/outfile. So if PS output has three lines as output i want to log these three lines into ...

Open Source Development

I am a Fedora12(GNOME) user. I recently started development in Linux. Most of the Linux system applications/utilities are written in c/c++. The problem i am facing is that how to integrate a downloaded source code with some IDE(e.g, Anjuta etc). In simple words i want to know that, what is the best way to start development on some exis...

linux script that monitors file changes within folders (like autospec does!)

I want to automatically kick off a build whenever a file changes. I've used autospec (RSpec) in Ruby and loved that. How can this be done in bash? ...

How to setup the serial port?

Hi, I'm using Linux OS as a programming platform. And I want to create a program that uses serial(/dev/ttyS0) port as a communication medium. I already know how to open, read, write and close the serial port using standard Linux function. Now my question is how can I able to setup the serial port? What I mean is I want to change the se...

How to prepend/(insert a string) in a file at arbitrary line numbers to multiple files in a directory?

Appending can be done using tee command. cat file | tee -a >> * Is there a way to do a prepend/insertion? Thanks. ...

setting Java Classpath in linux ???

I downloaded apache-log4j-1.2.16.zip unziped . renamed it as LOG4J_HOME and placed it in /home/appnetix folder which is my folder. Now I'm setting the classpath using terminal by the following command :- [appnetix@Sanjeev ~]$ set classpath=%path%;LOG4J_HOME/log4j-1.2.16.jar; & I got this bash: LOG4J_HOME/log4j-1.2.16.jar: Permission den...

in k_rem_pio2 file function is there any number which not hold carry!=0 for ih==2 case?

I'm working on application using the math computation. For my code I need to know how to cover all paths of code of libraries I'm using. The one of not covered yet is in k_rem_pio2 file. The kernel function have branch for ih==2 numbers and then ther is an if(carry!=0) -z= scalbn(one,q0); my question is for what number the i...

Mercurial and Hudson on web hosting. Can I install Mercurial

Hi, I have a hosting package where I have a private Tomcat and I run Hudson. I wanted to start using Mercurial and BitBucket (which is fantastic btw), my problem is that Hudson or the Mercurial plugin doesn't bundle Mercurial in the same way it does Subversion and you have to point your plugin to your Mercurial install. My hosting does...

Correct word-count of a LaTeX document

I'm currently searching for an application or a script that does a correct word count for a LaTeX document. Up till now, I have only encountered scripts that only work on a single file but what I want is a script that can safely ignore LaTeX keywords and also traverse linked files...ie follow \include and \input links to produce a corre...

strange error in running executable files (linux)

I try to run an executable file on newly installed Ubuntu and I get this strange error >./hadoop hadoop : Not a directoryh >hadoop hadoop command not found the first error says "directoryh", what is the reason for these messages ...

How can I keep memory from exploding when child processes touch variable metadata?

Linux uses COW to keep memory usage low after a fork, but the way Perl 5 variables work in perl seems to defeat this optimization. For instance, for the variable: my $s = "1"; perl is really storing: SV = PV(0x100801068) at 0x1008272e8 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x100201d50 "1"\0 CUR = 1 LEN = 16 When you use tha...

/usr/bin/ld: cannot find -lemu

I am attempting to install an application. During compilation it fails with the following error: /usr/bin/ld: cannot find -lemu I have installed the libemu library, and it now currently resides in /opt/libemu/. However, when I try and compile my application the library is not found. Is there any way to correct this? EDIT: It also l...

Regular expression with sed

Hey I'm having hard time selecting from a file using a regular expression. I'm trying to replace a specific text in the file which is full of lines like this. /home/user/test2/data/train/train38.wav /home/user/test2/data/train/train38.mfc I'm trying to replace the bolded text. The problem is the i don't know how to select only the bol...

Stopping process in /etc/inittab kills spawned process. Doesn't happen in rc.local.

Hi, I'm trying to execute a firmware upgrade while my programming is running in inittab. My program will run 2 commands. One to extract the installer script from the tarball and the other to execute the installer script. In my code I'm using the system() function call. These are the 2 command strings below, system ( "tar zvxf tarbal...

How to exchange data between programs using the terminal?

I have a program which continually receives data from an external source and prints it to the terminal. I am now trying to create a GUI to display the received data. Is there some way for me to do this without changing the pre-existing code (that is the old code calls a print statement and what is printed gets displayed in the GUI)? ...

How to "zero" a file with 1's

I'll often create a file of a particular size with a trick like dd if=/dev/zero of=1gb.dd bs=1M count=1024 or perhaps even dd if=/dev/urandom of=1gb.dd bs=1M count=1024 dd if=/dev/random of=1gb.dd bs=1M count=1024 But what if I want to get all 1's instead of 0's or random? ...

automatically restart an application after a core dump

I have a linux process but I am taking some core dumps some times. Simple question: Is there any way/method/program/whatever that is capable of restarting a process that got killed? Thanks. ...

Deleting a folder that contains symlinks

If I rm -rf a folder that has soft links in it, will it try to follow those links and delete the corresponding folder, or will it simply unlink them? I have a copy of my home directory with sym links in it, and I'm scared to rm -rf it in case it follows those links and blows up the corresponding folders... ...

How to repair Java in Ubuntu after trying to switch to Java 6 using update-java-alternatives

I tried to switch from Java 5 to Java 6 using the "update-java-alternatives" command like explained on this page: https://help.ubuntu.com/community/Java But afterwards I get the following error when I tried to execute java: root@webserver:~# java Error occurred during initialization of VM Could not reserve enough space for object heap ...