unix

gcc options for fastest code

I'm distributing a C++ program with a makefile for the Unix version, and I'm wondering what compiler options I should use to get the fastest possible code (it falls into the category of programs that can use all the computing power they can get and still come back for more), given that I don't know in advance what hardware, operating sys...

test remote file if directory

HOSTNAME=$1 #missing files will be created by chk_dir for i in `cat filesordirectorieslist_of_remoteserver` do isdir=remsh $HOSTNAME "if [ -d $i ]; then echo dir; else echo file; fi" if [ $isdir -eq "dir" ] then remsh $HOSTNAME "ls -d $i | cpio -o" | cpio -id else remsh $HOSTNAME "ls | cpio -o" | cpio -id fi done i need simple sol...

echo value inside a variable ?

x=102 y=x means when i echo $y it gives x echo $y x --and not 102 and when i echo $x it give 102 lets say I dnt know what is inside y and i want the value of x to be echoed with using y someting like this a=`echo $(echo $y)` echo $a Ans 102 ...

grep value inside a variable pointing to other variable

using : ksh *abc = 1 efg = 2 hgd = 3 not known to me * say if i have Value="abc efg hgd" abc efg hgd all contains some value which i dnt know. Now I want to grep the value contained inside abc. like for i in $Value do grep "echo $(($((echo $i | cut -d'|' -f2))))" done this grep should look for the value...

How does the #! work?

In a script you must include a #! on the first line followed by the path to the program that will execute the script (e.g.: sh, perl). As far as I know though, the # character denotes the start of a comment and that line is supposed to be ignored by the program executing the script. It would seem though, that this first line is at some p...

What benefits can Java developer have from moving to a *NIX platform?

Hi everyone, A friend of mine is a Java developer, who's using *NIX for ages. He claims that *NIX is for real Java geeks, whereas WIN is for dummies (and I'm one of them, according to him) and girls. When I ask him to argue his position, and explain, what's so good for Java developer on *NIX, he starts talking about console, wget, curl ...

shell scripting arithmetic operations

in general i will use expr inside shell scripts for doing arithmetic operations. is there a way where we can come up with arithmetic operation in a shell script without using expr? ...

Confusion in bind call in socket programming

i was learning socket programming in unix using c/c++. I am confused with one function call bind(params..). Actually it takes the adreess structure "sockaddr_in" and we can create the structure in the following way sockaddr_in.*** = somthing.. sockaddr_in..s_addr htonl(INADDR_ANY) **Passing INADDR_ANY will alow to bind all local add...

Catching / blocking SIGINT during system call

I've written a web crawler that I'd like to be able to stop via the keyboard. I don't want the program to die when I interrupt it; it needs to flush its data to disk first. I also don't want to catch KeyboardInterruptedException, because the persistent data could be in an inconsistent state. My current solution is to define a signal h...

Reading data from a unix device

On one of my RedHat Linux Servers a couple devices have been setup. /dev/ap and /dev/reuter. They are AP and Reuters news feeds. At the unix command line I can do "cat /dev/ap" and it waits until a message comes down the feed and prints it out to stdout. As soon as there is a pause in the stream cat completes. I tried "more" and got the ...

How to run a program without specifying the full path?

How come when I type "rails", it won't work... but when I type "/var/lib/gems/1.8/bin/rails" it will work? How do I bind it so that I don't have to type the full path everytime? ...

Different search paths for tclsh

Any one knows how can I invoke the tclsh in the Tcl code due to different paths to tclsh in various platforms (Linux, SUN)? For example in SUN: #!/usr/bin/sun/tclsh in Linux: #!/usr/bin/linux/tclsh How can I use the same Tcl code and execute it in the above two paths? ...

Problem with graphviz on Unix

When I'm on Unix, my graphs with graphviz are less nice. The tail or the head of the edge is not always linked to the boundary of the port. You can see the result here : http://www.freeimagehosting.net/image.php?59d8eb4b30.jpg <xsl:value-of select="$source"/>:<xsl:value-of select="$prot"/> -&gt; <xsl:value-of select="$destination"/...

Copy a directory while preserving symlinks using Java File/IO APIs

Is it possible to copy directory contents using the Java I/O and File-related APIs while preserving existing symlinks? I am working on a tool that needs to perform "directory copy" operations on a variety of UNIX flavours while preserving existing symlinks. I'd prefer to attempt this using the core Java SE libraries without resorting Ru...

Can I install WhizzyTeX for Emacs on a Mac (is Mac OS X a unix environment)?

I think my question is pretty stupid, but here it goes: I am using Aquamacs, and I want to install the WhizzyTeX mode. The website for WhizzyTeX says that "it is designed for Unix platforms". I read that Mac OS X is unix certified, but does that mean I can install WhizzyTeX on my mac? If yes, can I install and use it with Aquamacs or ...

Sorted directory size display in Unix

How do i display directory sizes in a sorted manner in Unix while listing only innermost sub-directories? For example, I don't want get to something like this - 100270480 /a/b/BP/b/bat/qc3 100270416 /a/b/BP/b/bat/qc3/logs 99020464 /a/b/BP/b/bat/qc3/logs/i 99005456 /a/b/BP/b/bat/qc5 99005408 /a...

Execute Command Line Java program in background

Is it possible to execute a Java program in the background so the user can execute other commands in front of it? For instance, here is how the console might look for said program: $ myProgram (executes program) Program Started! (output from myProgram) $ (the user can enter another UNIX command while myProgram is still running) Th...

C++: How would I get unix time?

I need a function or way to get the UNIX epoch in seconds, much like how I can in PHP using the time function. I can't find any method except the time() in ctime which seems to only output a formatted date, or the clock() function which has seconds but seems to always be a multiple of 1 million, nothing with any resolution. I wish to ...

how to check if a path is actual or symbolic link

Hi, I am writing my own shell program. I am currently implementing the cd command using chdir. I want to implement the cd with the below options : -P Do not follow symbolic links -L Follow symbolic links (default) My query is that , when a given path is entered on the shell how to figure out if the path is a symbolic link or an...

How to create a new environment variable in UNIX....???

How to create a new environment variable in unix and use it in a program?????? ...