need help creating a shell that generates another shell

hi all,

i'm trying to create a shell script that browse files in a directory and generates another shell script based on these files.

for ex:

/tmp/files/ is the directory i want to browse and it has 2 files file1.sh and file2.sh.

now my shell script should browse /tmp/files/ and generate main.sh and in it should be something like

# Contents of main.sh
sh file1.sh
sh file2.sh

any suggestions?

thanks

Suggestion: one for loop, one echo, one redirection. For more information please tell me of the real-world application (aka "why it's not homework")

hi,

thanks for the info.

basically, to make my task easier i wanted to automate this process. my team lead normally gives me these LDT files that i need to upload to our database and i use the FNDLOAD command to do it. he gives me approximately 50 files a day and then i manually create the shell script for this.

i.e.
-----
FNDLOAD $1 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct "$fndload_ldt_dir/CP_XXAPCHKINVALIDCHARREPORT_US.ldt" \
WARNINGS=TRUE
FNDLOAD $1 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct "$fndload_ldt_dir/CP_XXAPIICR_US.ldt" \
WARNINGS=TRUE
FNDLOAD $1 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct "$fndload_ldt_dir/CP_XXRLAPPREPAYTREP_US.ldt" \
WARNINGS=TRUE
-----

the above commands are what i place inside my shell script and the files CP_XXAPCHKINVALIDCHARREPORT_US.ldt, CP_XXAPIICR_US.ldt, and CP_XXRLAPPREPAYTREP_US.ldt are given by my team lead. these files contains data for upload.

thanks

Wouldn't it be easier to create one script expecting 4 parameters (your current $1 plus the 3 filenames) that you can call quickly instead of creating a new script for each set of files?

that would be a problem since he gives me at least 50 files a day.

If you really insist on manually creating a script for each set of files, you can create a global caller script by running

echo '#!/bin/sh' > /path/to/main.sh
for script in /path/to/scripts/*.sh
do
    echo "sh ${script}" >> /path/to/main.sh
done
chmod 0700 /path/to/main.sh

However, I still think that for a repetitive task like that a more general script would be better suited. If you can give more information on the task I could (try) to help you with it.

thanks.

i'm currently building my shell script based from all your information.

i'll let you know how it turns out.