read files from folder and then call another script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read files from folder and then call another script
# 1  
Old 11-01-2007
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  
Old 11-06-2007
read files from folder and then call another script

Hi,

Can somebody give some idea on this.

Thanks
# 3  
Old 11-06-2007
Code:
find sourceDir -type f | while read N
do
       if someScript.sh "$N" log/`basename "$N"`.log
       then
              mv "$N" success
       else
              mv "$N" failure
       fi
done

Of course what this does not do is check for duplicate filenames etc.

Last edited by porter; 11-06-2007 at 06:55 PM..
# 4  
Old 11-06-2007
Seems pretty simple.

Code:
for FILE in $INPUT_FOLDER/*; do
  Script2.sh $FILE /log/${FILE##*/}.out
  if [[ $? -eq 0 ]]; then
     mv $FILE $SUCCESS_FOLDER
  else
     mv $FILE $FAILURE_FOLDER
  fi
done

Something like that?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

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... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Read files into variable using then pass to delete call

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... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Shell Programming and Scripting

Bash script read specific value from files of an entire folder

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 ... (1 Reply)
Discussion started by: ahmenty
1 Replies

4. Shell Programming and Scripting

Read line of files and call store procedures

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.... (8 Replies)
Discussion started by: newbie2011
8 Replies

5. Shell Programming and Scripting

How to create a shell script to read a foldername from a text file and go to the folder?

Hi, I am trying to write a shell script which can read folder names from a text file and then go to the folder and picks up a xml file and write on my sipp script so that I can run the sipp script. For example: I have a text file called thelist.txt where I have provided all the folders... (7 Replies)
Discussion started by: pm1504
7 Replies

6. UNIX for Dummies Questions & Answers

Script for checking the files in a folder

Hi , I am using the below script for checking for a file in a folder. if ; then echo 0 else echo 1 fi Is there any way we can check for files which are starting with GL*.csv.What I am trying to do is , I have to check in a folder for the GL*.csv files if there are any files they I... (6 Replies)
Discussion started by: wangkc
6 Replies

7. Shell Programming and Scripting

Running a script with all files in a folder

Hi I have many files in a folder (like 200) and I want to run a Perl script through all of them. One way would be to do it one by one (which will take forever). But I am sure there is a faster way of doing it. So inside the folder i have files named in no particular way eg. YUI456... (3 Replies)
Discussion started by: phil_heath
3 Replies

8. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

9. Shell Programming and Scripting

shell script to call other files..plz help

Hi all, I have a number of shell script,perl script.. etc in a directory,which i need to execute in some order.Now i need to create a script to call all these files in that order..so that the new script will execute all the files one by one....plz help this is urgent. Thanks In advance Anju (3 Replies)
Discussion started by: anju
3 Replies

10. UNIX and Linux Applications

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... (1 Reply)
Discussion started by: girishnn
1 Replies
Login or Register to Ask a Question