unix

Strangeness using /usr/xpg4/bin/tr and /usr/bin/tr on Solaris 9

Hi all, I have a file looking like this, "xxxxxx" "yyyyyy" "aaaaaa" "cccccc" "bbbbbb" "eeeeee" "oooooo" "zzzzzz" Wanting to replace each \n in this file I use: tr '\n' ',' < INPUT > OUTPUT Which works fine. The output is to be expected: "xxxxxx","yyyyyy","aaaaaa","cccccc".... However I can't do any manipulation using sed or aw...

fopen and open produce files with different file permissions

These two code snippets produce files with different file-permissions. Example 1 creates the expected default file-permissions but Example 2 does not. What's the explanation for this? OS: Mac OS X version: 10.6.4 Xcode version: 3.2.2, 64 bit // Example 1 FILE *fh1 = fopen("Test1.txt", "w+x"); if (fh1) { fwrite("TEST1", 1, 5, fh...

how to ssh onto a host without password using java

Hi All Im currently using a java application to run commands on a unix box by invoking an instance of the bash as follows -- proc = Runtime.getRuntime().exec("/bin/bash", null, wd); and Im executing commands on the box by Printwriter as follows -- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getO...

escape string and make it unix ready

I would like to take a string that may have multiple spaces in it and do the following: 1) Replace whitespace with an underscore 2) Remove any characters that are not A-Z or 0-9 3) Make the result all lowercase Then be able to use the result as a variable. Any ideas? ...

CentOS CPU usage

Is there a way to get CPU usage in CentOS? I need to parse this information and graph it from a Perl script, so it should preferably be a simple tool that prints out one singular output. ...

Why is malloc not async signal safe?

Why can't malloc be used in signal handlers? What can "happen wrong"? ...

How to make a line as a comment in SED

Excuse me if it is a repeat. I have crontab entries which look like: * * * * * sleep 15;/etc/opt/wer.sh 1 * * * * /opt/sfm/qwe/as.sh How to insert a # on the line which contains a call to "as.sh" using sed? How to uncomment it back? ...

Testing Condition on File permission

Hi, i am learning shell scriptnig, is there any way i can test the operation like checking file permission on a file.. like... i know some of the way like. searching the file through find command using permission, or in "ls...| grep 'r--r--r' smthg.. whatever permission u wan't I have some file how i check whether the file have the requ...

Java: Date from unix timestamp

Hi I need to convert unix timestamp to date. I did it like this: java.util.Date time=new java.util.Date(timeStamp); timestamp value is: 1280512800 and time must be "2010/07/30 - 22:30:00" (as I get it by PHP) but it is "Thu Jan 15 23:11:56 IRST 1970" by the code above! What's the problem? ...

Read/write data from command line using PHP

Hey everybody, I have a server (debian lenny), spectral analyzer and I have downloaded collection of source codes from Steve Sharples's site. With these s. coudes I am able to connect to spectral analyzer - type command and get the responce. For example: my-atom:~/vxi11# ./vxi11_cmd 135.123.106.59 Input command or query ('q' to exit):...

Number of digits in Epoch time

I'm working on a machine which has some code running on it which sets the time when I set the password. The time set is epoch time, but it has 13 digits in it, and when I wrote a simple program to get the epoch time and ran it on my personal computer running linux, it returns the epoch time which has 10 digits. Would anyone know what the...

In UNIX, how do I send a message to another UNIX box on the same network by IP address?

Just like a "net send" on Windows, if I remember what net send does correctly. I just want to say something like: <command> <IP address> "Hey what's up?" and the message "Hey what's up?" should show up on the other guy's machine. Ideally this shouldn't require installation of any packages not already present in typical UNIX/Linux dist...

Pretty Print HTML in Ruby (or Shell)

Is there any way to pretty print an HTML or XML string from the command line on a mac? Trying to do this in Ruby. Any ideas? I've thought about XSLT, and about writing my own parser, but both of those are pretty involved. Looking for something already out there. ...

On OS X, how do I find out what architecture a shared lib is compiled for?

I need to know whether I compiled libjpeg for 32 or 64 bits architecture, but don't know how to find out, is there a command that will let me check? ...

How to reverse order of fields using AWK?

I have a file with the following layout: 123,01-08-2006 124,01-09-2007 125,01-10-2009 126,01-12-2010 How can I convert it into the following by using AWK? 123,2006-08-01 124,2007-09-01 125,2009-10-01 126,2009-12-01 ...

Hide Last Modified time on apaches directory index/listing

Hi, I have this set up in my .htaccess Options +Indexes IndexOptions -FancyIndexing but even with -fancyindexing, it shows the modification time. How do you disable this? thanks ...

Regarding access time unix

I want to know what is access time . searched in web but get the same definition (read- gets changed). I know with touch we can change it. Could any one explain me more about it with an example how it is changed. Also is there any way file creating date/time be found in unix? ...

how to send mail to a mailing list with java?

Hi, I want to send a mail to a mailing list every period of time (like every 40min or hour) with java on a unix server. I'd like any code or tutorial to be able to do this. Thanks ...

spawn terminal reading its stdin

Hi all, I'm writing (under linux or windows+cygwin) a java program that needs to run a command (process P1) and read its stdout (which is mostly binary data useful to my program). This is easy to do, and already done. The problem is that P1 also prints some status informations on stderr, and I would like to spawn a terminal (like xter...

Is the "The UNIX System Interface" chapter of "The C Programming Language" still relevant?

I started reading The C Programming Language and I have now reached "Chapter 8: The UNIX System Interface." Is that chapter worth reading and still relevant as of today? ...