unix

UNIX cc executable location

When I compile a .c file using the cc command, it creates an a.out executable. I've noticed that it creates the a.out file inside my current directory. Is there a way to make the a.out file be created in the same directory as the .c file wherever I happen to be on the system? for example if my current path is ~/desktop and I type in t...

How do I get started writing a daemon process in a Unix-like operating system, like Linux?

I am doing a tool in PHP for my personal use. But PHP is very slow and the task I need to do is takes much time, so I'll make a daemon in c++ and keep it in the background (It will run in a VPS). PHP would connect to the daemon througt a simple tcp socket (I'll try to design/use a simple IPC protocol) in order to submit the task. The d...

Directory last modified date

Hello, Am wondering when the directory last modified date is changed. I modified a file inside a particular directory (via FTP), but the directory's LMD did not change. How is it suppose to function? Thank you for your time. ...

Sorting records in unix

On Unix: I have a text file that has records that I need to sort in ascending order of date and time. I have looked at the sort command and couldn't get it to work for me. Could someone please help me with this? Or point me in the right direction? { DateAndTime : "2010-08-27-11.42.43.082-0400", TestString:"123", TestData : { ...

Running an executable file on Ubuntu

I am trying to run a C/C++ program on Ubuntu. So at first g++ didn't work at all in the shell, so I installed it using the command sudo aptitude update && sudo aptitude install g++ so it installed it, and when I wrote the most simplest program it compiled g++ -Wall a.cpp -o d But when i tried to execute it just wrote "d" on the c...

How to run same tests on different servers using prove?

I am using the Perl prove testing utility (TAP::Harness) to test my program. I need to run the same tests first on a local computer, then on a remote computer. (Test programs should connect to localhost or to remote host, respectively) How can I pass parameters (test_server) to tests using prove? I should use environment or there is bet...

Techniques to provide a shared build environment on Windows and Unix

I'm certain this has been asked before, with with nearly 900k questions, it's hard to find things :) We are starting a project where we want our C++ and Python to run both under a Unix environment but also under Windows. We want to make our project easy to contribute to as developers, and so we wish to have what each side feels is "nat...

Any method for going through large log files?

// Java programmers, when I mean method, I mean a 'way to do things'... Hello All, I'm writing a log miner script to monitor various log files at my company, It's written in Perl though I have access to Python and if I REALLY need to, C (though my company doesn't like binary files). It needs to be able to go through the last 24 hours, ...

Zip command without including the compressed dir itself.

Suppose the structure: /foo/bar/ --file1 --file2 --file3 --folder1 --file4 --folder2 --file5 I want to run the unix zip utility, compressing the bar folder and all of it's files and subfolders, from foo folder, but not have the bar folder inside the zip, using only command li...

c/unix: abort process that runs for too long

I need to kill such user processes that are taking longer time than a said expected interval on UNIX (Solaris) operating system. This needs to be done inside the process that is currently being executed. Please suggest how this can be achieved in C or in UNIX? ...

Appending output to a file at the same time truncating it to N lines

Hello all, I'm trying to find a simple way to append/write to a log, while at the same time keeping it the log trimmed to a reasonable size. I would prefer to not just append files forever, and then have to have a clean up log script. I can't wrap my head around how I would accomplish this gracefully without using some second file as a ...

Error installing ImageMagick-6.6.3-10

I'm trying to install ImageMagick-6.6.3-10. I've downloaded and extracted the tar file and ran make install as root. When running make check it says "1 or 48 tests failed". The failed test is: FAIL: Magick++/tests/attributes.sh Any ideas what to do from here to get to resolve the failed test so everything's working properly? (I'm runn...

Parsing using awk or sed in Unix

Hi, I have multiple files with hundreds of thousands of records in following format: 2010/08/10 10:07:52|TrainZoom|1393|38797|MyCustomerAPI->,mask = ZPTA,TransId = 1281460071578,testing :-> , capture -> : , IMDB = 9113290830, equipmentName = GMT, technologyName = RMS,,,)| There are fields separated by pipes and inside...

Find classes within Jar

Hi , I have a jar file and I want to know which all classes are within it. Is there any way I can do that? ...

Using C# to call perl script on a Unix box

I need to execute Perl script (basically job submission) sitting on a Unix box. This needs to happen from a C# application sitting on a Windows box. Is this entirely possible? If so, where do I start? Any reading material would be helpful! ...

Get the begining and ending unix timestamp for a given month and year in php

Hay, I want to find the timestamp for the first day in a month (say September 1 2010 and 0:00) and the last day in a month (say September 31 23:59). Any ideas how to do this? ...

What is the use of second structure(*oldact) in sigaction()

Hi, I am trying to create a handler for the exit signal in c and my operating system is ubuntu. I am using sigaction method to register my custom handler method. int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); Here's my code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signa...

Deleting a broken link Unix

I want to delete a broken link, but before that I want to confirm if the link file is present in directory. Let's call the link A: if [ -a A ] then print 'ya A is ther' fi But if A is a broken link then how can I check? ...

I'd like to run a command over ssh from a windows box running using c#

Note that this has to be on a windows box as I am using c# to access information about windows (I need information from both a windows box and a linux box, plus I think that making a program/script that runs without gui and accesses windows from a linux box without user intervention would be more difficult, if this is not true please te...

Can't handle Floating Point Exception (FPE) for the second time.

I have written a program that handles signal for Floating point exception and I am using Ubuntu 10.4. Here's my source code : #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <setjmp.h> sigjmp_buf mark; void GeneralHandler(int signo) { switch(signo) { case SIGFPE: printf("\nERROR : Inva...