What's the preferred way to determine if a given ksh invocation is running an interactive shell?
I have some commands in an ENV file that I would like to skip for non-interactive ksh invocations (e.g. when executing a shell script).
I've seen suggesting ranging from:
if [[ $- = *i* ]]; then
# do interactive stuff
fi
...to not ev...
I have a 600MB tab delimited file that needs to be sorted using only the first two columns. Any lines already in order by those columns should remain in the existing order. My efforts using sort and --key seem to keep sorting the lines by the other columns.
This is an example of the unsorted file:
1244072768 7234 Z
1244072768 7234 e...
Here's a simple Ruby script:
puts `ls -laG`
In OS X's ls, -G is for color.
When run under bash, I get color output. When the above is run from a Ruby script, I don't see color or the ANSI escape sequences in the resulting output.
From what I've read, my guess is it's because the script isn't running as a tty. Is there some way to ru...
Have the following cronjob set up in root's crontab: (centos 5.x)
2 * * * * /usr/bin/curl --basic --user 'user:pass' http://localhost/cron/do_some_action > /var/www/app/cronlog.log
Invoking the actual command works as expected, however when the cronjob runs, it always times out. I've used set_time_limit() and related php.ini settings ...
Suppose I have two files, A and B, and that lengthOf(A) < lengthOf(B). Is there a unix utility to tell if file B duplicates file A for the first lengthOf(A) bytes?
If I do "diff A B", the output will be all the 'extra stuff' in the B file, which misses the point; I don't care what else might be in file B.
If I do "comm A B", then I hav...
Hey,
I've being trying to figure this out, but nothing seems to work. We have an application
that reads thousands of transactions files using the normal "fopen fgets etc", which we parse using normal C functions "strstr, strchr, etc" and return back a normalized char *.
However, now we need to read some files that are in Unicode (from ...
I was just wondering what the implication is for running a script as a daemon versus using nohup?
I know what the difference is terms of forking processes etc, but what impact does that have on my script?
...
A python program needs to draw histograms. It's ok to use 3rd party library (free). What is the best way to do that?
...
Possible Duplicate:
Why do programs in Unix-like environments have numbers after their name?
What does the (1) mean?
...
I am writing a script to capture disk usage on a system (yes, I know there is software that can do this). For database reporting purposes, I want the interval between data points to be as equal as possible. For example, if I am polling disk usage every 10 minutes, I want every data point to be YYYY-MM-DD HH:[0-5]0:00. If I'm am pollin...
Hi All,
I'm writing a cross-platform TCP/IP server and I need to authenticate users before servicing them. Requirements stipulate that I use "native" authentication of the platform and not create my own authentication mechanism.
For Linux/Unix OS family I use getpwnam to authenticate users and the most reliable way I know to make sure ...
G'day,
I need to see if a specific file is more than 58 minutes old from a sh shell script. I'm talking straight vanilla Solaris shell with some POSIX extensions it seems.
I've thought of doing a
touch -t YYYYMMDDHHmm.SS /var/tmp/toto
where the timestamp is 58 minutes ago and then doing a
find ./logs_dir \! -newer /var/tmp/toto -pr...
For example, I might want to:
tail -f logfile | grep org.springframework | <command to remove first N characters>
I was thinking that 'tr' might have the ability to do this but I'm not sure.
Thanks in advance stackoverflow geniuses!
--
LES
...
I'm running a Solaris server to serve PHP through Apache. What tools can I use to measure the bandwidth my server is currently using? I use Google analytics to measure traffic, but as far as I know, it ignores file size. I have a rough idea of the average size of the pages I serve, and can do a back-of-the-envelope calculation of my band...
I do not have ssh access to a machine with htdigest and I use Windows. Can someone help me?
...
I have a log file which contains a number of error lines, such as:
Failed to add [email protected] to database
I can filter these lines with a single grep call:
grep -E 'Failed to add (.*) to database'
This works fine, but what I'd really like to do is have grep (or another Unix command I pass the output into) only output the email ad...
I have been using this script of mine FOREVER and I have always been using "~/" to expand my home directory. I get into work today and it stopped working:
#if ( $output eq "" ) { $output = "~/tmp/find_$strings[0].rslt" } # BROKEN
if ( $output eq "" ) { $output = "$ENV{HOME}/tmp/find_$strings[0].rslt" } #WORKS
...
open OUT_FILE,...
Hi,
I'm trying to figure out how to redirect output from some FORTRAN code for which I've generated a Python interface by using F2PY. I've tried:
from fortran_code import fortran_function
stdout_holder = sys.stdout
stderr_holder = sys.stderr
sys.stdout = file("/dev/null","w")
fortran_function()
sys.stdout.close()
sys.stderr.close()
sys...
I have an interesting (at least to me) problem: I can't manage to find a way to reliably and portably get information on grandchildren processes in certain cases. I have an application, AllTray, that I am trying to get to work in certain strange cases where its subprocess spawns a child and then dies. AllTray's job is essentially to d...
When defining a path to a directory as a variable or constant, should it end with a trailing slash? What is the convention?
pwd in unix shows your current directory without a trailing slash, while the tab complete of cd /var/www/apps/ includes the trailing slash, which left me unsure.
...