
10-13-2008
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by eisenhorn
Code:
...
gzip_func() {
started=0
threads=4
for filename in `ls -1 ${EXP_DIR}/*.dmp`
|
Not only is -1 unnecessary, but so is ls itself. Also, ls will break your script if there are any spaces in the filenames.
Code:
for filename in ${EXP_DIR}/*.dmp
Quote:
Code:
do
if [[ ${started} -lt ${threads} ]]; then
let started=started+1
|
Use standard syntax:
Code:
if [ ${started} -lt ${threads} ]; then
started=$(( $started + 1 ))
Quote:
Code:
echo "gzip ${filename}"
( $GZIPCMD ${filename} ) &
|
Quote the variable, or your script will break if there are spaces in the filename (and there's no need for the parentheses):
Code:
$GZIPCMD "$filename" &
Quote:
Code:
list_of_pids="${list_of_pids} $!"
else
print "wait ${list_of_pids}"
wait ${list_of_pids}
list_of_pids=""
started=0
fi
done
}
...
my_binary_file_creation_process
...
while [ `find ${EXP_DIR} -name \*.dmp|wc -l` -gt "0" ]; do
|
What wrong with:
[code]
for
Quote:
Code:
gzip_func
print "wait ${list_of_pids}"
wait ${list_of_pids}
list_of_pids=""
done
Can anyone help me write some code for this using standard solaris 8/9/10 tools using the korn shell. Perl commands should be possible (vers 5.6.1 installed).
|
Your code looks far more complicated than it needs to be.
It's not clear from your code how you tell whether a file is finished being written to so that you can compress it.
Do you have any control over the process that is writing the binary files?
|