I have a parallelized automation script which needs to call many other scripts, some of which hang because they (incorrectly) wait for standard input or wait around for various other things that aren't going to happen. That's not a big deal because I catch those with alarm. The trick is to shut down those hung grandchild processes when t...
I have a simple Ruby script that looks like this
require 'csv'
while line = STDIN.gets
array = CSV.parse_line(line)
puts array[2]
end
But when I try using this script in a Unix pipeline like this, I get 10 lines of output, followed by an error:
ruby lib/myscript.rb < data.csv | head
12080450
12080451
12080517
12081046
12081048
...
#!/usr/bin/perl
This is the shebang line to a lot of scripts I'm writing lately.
Hard coding the path of the binary seems like it could create some problems. For instance, if one of my users has Perl installed at /something_else/bin then they'd have to change all the shebangs.
I've seen some tools that will automatically replace the ...
I am writing a program on linux gcc...
When I tried to include <math.h> I found that I need to link math library by using command gcc -lm
But I am searching for another way to link the math library 'in code', that does not require the user to compile using any options..
Can gcc -lm be done in c code using #pragma or something?
EDIT:...
Newbie question:
On Unix, in a program with a parent and some children:
- How can the parent alert the children efficiently to do some work.. ?
- Or how can the children wait for parent signal to start doing some work?
EDIT:
This program tries to do a complex computation in parallel, I have already used shared memory as a common works...
I want to ask about UNIX time, Does UNIX time record Timezone?
I moved my hosting from Chicago/America to JST.
The problem is that my whole MySQL database has records of UNIX time (Chicago/America timezone)
I have a PHP code to show the time ago (ex 3days ago, yesterday, etc)
When I move to the new server it says tomorrow
To avoid th...
http://gcc.gnu.org/install/binaries.html
This page has the binaries. Which one would work for Fedora?
...
Using Solaris
I have a monitoring script that uses other scripts as plugins.
Theses pugins are also scripts which work in difffernt ways like:
1. Sending an alert while high memory uilization
2. High Cpu usage
3. Full disk Space
4. chekcking the core file dump
Now all this is dispalyed on my terminal and I want to put them in a HTML f...
In linux make file:
I want to run the output program only in case of successful compilation.
Is there a way to do this?
...
I'd like to have a shell script redirect stdout of a child process in the following manner
Redirect stdout to a file
Display the output of the process in real time
I know I could do something like
#!/bin/sh
./child > file
cat file
But that would not display stdout in real time. For instance, if the child was
#!/bin/sh
echo 1
sl...
Let's say I do this in a unix shell
$ some-script.sh | grep mytext
$ echo $?
this will give me the exit code of grep
but how can I get the exit code of some-script.sh
EDIT
Assume that the pipe operation is immutable. ie, I can not break it apart and run the two commands seperately
...
I have a java program that generates an HTML file. The Java program takes two input parameters: file1 and file2, the output file is specified by the "--file=".
When executed from the command line (UNIX, Mac OS 10.6.2) it looks like this:
"java -jar program.jar http://my.testsite.com/test1.html http://my.testsite.com/test2.html --file=...
In a unix environment, I want to use tee on a chain of commands like so
$ echo 1; echo 2 | tee file
1
2
$ cat file
2
Why does file only end up as having the output from the final command?
For the purpopses of this discussion, let's assume I can't break them apart and run the commands seperately.
...
File.chown takes an owner ID, a group ID (gid), and a filename. I want to use it to set a file's gid, but what I have is the group name. Is there anything in the standard library that I can use to translate a group name into a gid?
...
Is there an ipc option to get the last message in message queue but not removing it?
I want this to allow many clients reading same messages from the same server..
Edit:
Server and clients are on the same machine!
Thanks
...
I have a record of data with unix time date in it
i want to select the row based on the date/month/year only (not with time)
currently Im using something like this
select *
from tablename
where date > '$today'
and date < '$tomorow'
LIMIT 1;
how ever this is not that accurate if the $today and $tomorrow have different tim...
UNIX timestamp always in GMT?
I tried to run php function time()
and when I tried to convert the unix timestamp from the time() function, the output is not similar to the computer time.
Thank You
...
How do memory leak detection tools like purify and valgrind work?
How can I design and implement my own such tool?
...
I'm trying to point DocumentRoot at a directory in my user folder. While I can happily point DocumentRoot at /Library/WebServer/Documents and ~/Sites I keep getting "You don't have permission to access / on this server." when I point it anywhere else.
OK, I just found a solution mid-question (stack overflow is just that good) by changin...
I'm running an ANT task in background and checking in 60 second intervals whether that task is complete or not. If it is not, every 60 seconds, a message should be displayed on screen - "Deploy process is still running. $slept seconds since deploy started", where $slept is 60, 120, 180 n so on.
There's a limit of 1200 seconds, after wh...