The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX and Linux Applications Questions involving software not covered by other forum go here. This includes Databases and Middleware.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Auto copy for files from folder to folder upon instant writing Bashar UNIX for Advanced & Expert Users 1 04-15-2008 04:01 PM
shell script to call other files..plz help anju Shell Programming and Scripting 3 02-05-2008 12:07 AM
Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!! anju Shell Programming and Scripting 3 01-31-2008 09:47 PM
read files from folder and then call another script girishnn Shell Programming and Scripting 3 11-06-2007 02:53 PM
read system call Madhu Babu High Level Programming 1 11-16-2002 03:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-01-2007
Registered User
 

Join Date: Nov 2007
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
read files from folder and then call another script

Hi,

I am new to the Unix shell scripting world. It would be great if some body can help me with my requirement

1) Script (say script1.sh) which will take set of files from one folder (say input folder).
2) Take the first file from the folder and execute another script (script2.sh).Pass 2 parameters - one input file(file1) and another output file(file1.out).
Script2.sh /input/file1 log/file1.out (this script is already working)

3) On completion of the script2.sh – if it is a success then move the input file from the input folder to another (say success) folder. If the execution of script2.sh is a failure then move the input file from the input folder to another (say failure) folder
4) Repeat the step # 2 and #3 until all the files are processed from the input folder

Thanks in advance,
Girish
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-08-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 568
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
I might be misunderstanding your question but there's what I make of it:

You have a bunch of files.
You want to run your script over the files, one by one, moving them into either a success or failure folder depending on the outcome of the script. Right?

If so, I'd do something like this:
Code:
for file in <input file dir>/* ; do if script2.sh $file ${file}.output ; then mv $file <success dir>; else mv $file <failure dir>; fi ; done
If you want the output to move with the input file, add another mv command to each of the sections of the if statement.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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 -7. The time now is 09:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102