unix

Suppress find & grep "cannot open" output

I was given this syntax by user phi find . | awk '!/((\.jpeg)|(\.jpg)|(\.png))$/ {print $0;}' | xargs grep "B206" I would like to suppress the output of grep: can't open..... and find: cannot open lines from the results.sample output to be ignored: grep: can't open ./cisc/.xdbhist find: cannot open ./cisc/.ssh ...

Time triggered job Cron or Quartz?

I already asked a separate question on how to create time triggered event in Java: http://stackoverflow.com/questions/1029164/large-scale-time-triggered-event-handling. I was introduced of Quartz. At the same time, I also google it online, and ppl are saying Cron command in Unix is a neat solution. Which one is better? What's the cons ...

What is the BSD (or portable) way to get ToS byte (like IP_RECVTOS from linux)?

What is the right (portable, stable) way to get the ToS byte of a received packet? I'm doing UDP with recvmsg() and on linux I can get the ToS if I setsockopt() IP_RECVTOS/IPV6_RECVTCLASS, but IP_RECVTOS doesn't seem to be available on my BSD systems. What is the right way to do this? I primarily want this to work on the BSDs and Solari...

gprof reports no time accumulated

I'm trying to profile a C++ application with gprof on a machine running OSX 10.5.7. I compile with g++ in the usual way, but using -pg flags, run the application and try to view the call graph with gprof. Unfortunately my call graph contains all zeroes for all time columns. The values in the "called" columns have reasonable values so it...

Comprehending 'top' CPU usage

What does it exactly mean to have a 350% cpu usage (by a process) on a 4-CPU box? The process is a 'mysqld' which is currently being 'bombarded' by a simulated OLTP scenario. Any pointers appreciated. ...

PHP Time and Date

I have a database with dated articles. What I want to do is select articles between 2 dates - for example from 7 days ago to today. Can anybody help me. I have been trying to write a code for it but it hasn't worked for me. Thanks in advance ...

How to get a unix script to run every 15 seconds?

I've seen a few solutions, including watch and simply running a looping (and sleeping) script in the background, but nothing has been ideal. I have a script that needs to run every 15 seconds, and since cron won't support seconds, I'm left to figuring out something else. What's the most robust and efficient way to run a script every 15...

How do I use the bash time function from python?

I would like to use python to make system calls to programs and time them. From the Linux command line if you type: $ time prog args You get something along the lines of: real 0m0.110s user 0m0.060s sys 0m0.024s if you do a 'man time', it states that you can type: $ time -f "%E" prog args in order to format to get only...

Differentiate between a unix directory and file in C++

Given a path, say, /home/xyz/abc/def, I would want to determine if def is a directory or a file. Is there a way of achieving this in my C++ code? ...

Saving to a subversion repository from Java

I want to save to a subversion repository. I am using the command - svn commit -m \"\" ./cms_test/www My class is: public int doBackup(){ int exitVal=-99; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("svn commit -m \"\" ./cms_test/www"); exitVal = proc.exitValue(); System.ou...

Forcing the order of output fields from cut command

I want to do something like this: cat abcd.txt | cut -f 2,1 and I want the order to be 2 and then 1 in the output. On the machine I am testing (FreeBSD 6), this is not happening (its printing in 1,2 order). Can you tell me how to do this? I know I can always write a shell script to do this reversing, but I am looking for something us...

Raw socket NOT sending

I am trying to write a sample Raw socket program to clear my understanding of raw sockets. I create a Raw UDP socket and then call sendto. My sendto succeeds but I never see the packet received by the other side. I dont have any receive side running so I am relying on Wireshark running on both the sender and receiver. I am pasting the co...

Unix Sort with Tab Delimiter

I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort the file based on the last field decreasingly. I tried the following commands but it wasn't sorted as we expected. $ sort -k3nr file.txt # apparently this sort by space as delimiter $ sort -t"\t" -k3nr file.txt sort: multi-charac...

Prefered terminal scripting language

What language do you prefer writing scripts for common tasks (backup, sync, etc.) and why? I'm not talking about programing web pages or applications. I've got this question when thinking why bash is still popular. For example python looks more comfortable for me. Do you use just because you know it or for some special reasons? ...

What's the fastest way to check if a web site is up in Perl or C?

Hello all, I'm trying to check if a web site is up and running. I'm currently doing this with UserAgent library in Perl with timeout 1. However, it is still too slow for me. I call the script every five minutes from cron. There are lots of links to check and the script takes more than five minutes to complete execution. So, I need a mo...

Soap under Java 1.3 with Axis

I am writing a Java web service for legacy SCO machines (which only have Java 1.3 available). I have been able to get more recently-added XML parsing functions integrated by including the Xerces jar on my classpath. However Java is screaming about not being able to find javax.xml.soap, even though I've got Axis 1.3 and explicitly added a...

Remove all files in a directory

Trying to remove all files in a certain directory gives me the follwing error OSError: [Errno 2] No such file or directory: '/home/me/test/*' The code I'm running is import os test = "/home/me/test/* os.remove(test) ...

What is the best unix compression utility?

What is the best unix compression utility available? ...

Repeat Unix Command in Java

Is there a way to periodically run a Unix command (ps in my case) in Java? The loop I wrote: while( this.check ) { try { ProcessBuilder pb = new ProcessBuilder("ps"); Process proc; System.out.println(" * * Running `ps` * * "); byte[] buffer; String input; ...

Should different servers translate unix timestamps as different dates?

Whilst working on a UI update for a client, I noticed the dates associated with all the articles were out by a day. I figured I'd screwed something up during my changes, but to be sure, threw together a little php test file that gave me some odd results. The test file is just; <?php $date = 1246053600; echo 'unix: ',$date,', converted: ...