The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 03:06 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 10:15 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 07:05 AM
return valuse from child script to parent script borncrazy Shell Programming and Scripting 1 08-20-2004 03:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-28-2008
Movomito Movomito is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 27
Help with script

I have created the following script.

#!/bin/bash
#works list is any list that you give it, but it was designed to be used with the entire image volume list.
#for this script to have the most effect please run mobooksfiles/find-remove-empty-ebooks.sh befor running this.
if [ ! $2 ]; then
echo missing arguments\(s\)
echo rsync-from-file.sh \<works-list\> \<target-read\>
exit 1
fi

TARGET=$2
WORKLIST=/Users/tbrc/scripts/works2eBooks/$1
NOTEMPTY=/Users/tbrc/scripts/works2eBooks/mobooksfiles/notempty.txt
RESULT=/Users/tbrc/scripts/works2eBooks/mobooksfiles/result.txt

exec 3<&0
exec 0<$WORKLIST
while read line
do
cd $TARGET
find ./$line -type d \! \( -name "image*" -empty \) | awk -F'/' '{a[$2]++; if ( a[$2]==1 ) print "/"$2}' |
while read dir;
do
find .$dir -type d -name 'e*' | grep . && continue
echo "$dir" >$RESULT
done
done
exec 0<&3

#if you get rid of this line and the # before java below eBooks will be generated for the files found to have none from the above script
cd /Users/tbrc/scripts/works2eBooks
java -classpath pdflib.jar:. works2eBooks $TARGET $RESULT

exit 0




There are a few things that i dont understand that seem to be happening. The first is when i remove my >RESULT it outputs all of the files to the screen like this

./W2/eBooks/
./W3/eBooks/
./W4/eBooks/
/W5
but when i add >RESULT I still get this on the screen
./W2/eBooks/
./W3/eBooks/
./W4/eBooks/
and this to RESULT
/W5

Why is this happening? (I do like that it happens but am not sure why)

and issue number 2. It was outputting all of the directories that didn't have ebooks to RESULT but after some tinkering seems to only be outputting the first directory that it finds not to have eBooks to result.

my script then generates an ebook for it. So if i run it again it finds the next and so on but i obviously want it to output all of them at once. Any help would be great. And any suggestions on how to make it run even faster aside from what i have asked for would also be great.

Thanks
  #2 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The lines which don't end up in RESULT are the output from "grep ." I presume, i.e. directories which were found to already have an e* file. It would be customary to redirect the output from grep to /dev/null to avoid this, since the grep is only done for its truth value, not for printing the found directories; but of course, if you like it this way, don't change it.

You are overwriting RESULT on each iteration, so I guess it will generate an ebook for the last directory which lacks one, not the first. You can change it so it creates an empty RESULT before the loop, and then appends lines to it with >> (provided your Java thingy can cope with multiple file names in that file).
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0