read files from folder and then call another script

Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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
# 2  
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.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Request for Shell script to move files from Subfolder to Parent folder and delete sub folder
srivarun15
Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp...... Shell Programming and Scripting
6
Shell Programming and Scripting
Read files into variable using then pass to delete call
cmccabe
I am trying read all the files from list into a variable line using bash. After there are read into the variable they are passed to a delete call. The files appear to be read line (as I can see them with the echo) by line into the variable, but the delete call is not removing them and I do not...... Shell Programming and Scripting
1
Shell Programming and Scripting
Bash script read specific value from files of an entire folder
ahmenty
Hello, I heva a problem creating a script that read specifc value from all the files of an entire folder I have a number of email files into a directory and i need to extrect from each file 2 specific values. After that i have to put them into a new file that looks like that: To: value1 ...... Shell Programming and Scripting
1
Shell Programming and Scripting
Read line of files and call store procedures
newbie2011
Hi, I wish to write a piece of code to read lines of the flat file and cut each lines of record to a variable, then use this variable to pass as an parameter of a Sybase stored procedures, if there are 5 lines of record from the text file, then this stored procedures will be called 5 times....... Shell Programming and Scripting
8
Shell Programming and Scripting
read files from folder and then call another script
girishnn
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...... Shell Programming and Scripting
3
Shell Programming and Scripting

Featured Tech Videos