need help creating a shell that generates another shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help creating a shell that generates another shell
# 1  
Old 06-03-2009
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
# 2  
Old 06-03-2009
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")
# 3  
Old 06-03-2009
Quote:
Originally Posted by pludi
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
# 4  
Old 06-03-2009
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?
# 5  
Old 06-03-2009
Quote:
Originally Posted by pludi
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.
# 6  
Old 06-03-2009
If you really insist on manually creating a script for each set of files, you can create a global caller script by running
Code:
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.
# 7  
Old 06-04-2009
thanks.

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

i'll let you know how it turns out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with creating a simple shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell script that accepts two arguments. The two arguments are the name of 2 files. • If the arguments... (3 Replies)
Discussion started by: Scripter12345
3 Replies

2. Shell Programming and Scripting

Shell script that generates another shell script

If there's a file called example.txt with contents: Foo Bar Baz Goo then I need to generate a shell script that has commands to reconstruct example.txt on another machine: echo "Foo" >> example.txt echo "Bar" >> example.txt echo "Baz" >> example.txt echo... (5 Replies)
Discussion started by: Yongfeng
5 Replies

3. Shell Programming and Scripting

Need help in creating arrays using shell

Hi, I need help in creating a array in shell scirpt. I have a file which has following details. hostname devices device1 device 2 de abcdmhs10 1234 2343 2353 3343 3435 2343 bcdfmhs11 2343 2443 3434 8874 0343 3434 (5 Replies)
Discussion started by: jpkumar10
5 Replies

4. Shell Programming and Scripting

Help with shell script - creating users

echo -e "Enter in a username : \c" read username grep "^$username:" /etc/passwdWhat I'm trying to do is take in a username from my script and I need to be able to check if that username already exists. If it does the script should display a message saying that the user already exists and exit. ... (2 Replies)
Discussion started by: shadowcat
2 Replies

5. Shell Programming and Scripting

Creating simple shell program

Hi, I'm new to UNIX shell programming... can anyone help in doing the following : 1) create a text file named "Model File" having following columns : Name Number Physics Chemistry 2) prompt user to n rows enter the name, number, physics ,chemistry 3) display the entire columns and rows... (1 Reply)
Discussion started by: Mayuri P R
1 Replies

6. Shell Programming and Scripting

Bash shell: Creating Preferences

In OS X I'm currently writing a bash script that requires writing to preference file. I may eventually want to share it with users on other Unix-like OSs and would like to accommodate for that possibility ahead of time. Most OS X applications save preferences in xml-format plist files. These... (4 Replies)
Discussion started by: airsmurf
4 Replies

7. UNIX for Advanced & Expert Users

Creating database in shell, how?!

Hi, i'm newbie in Unix. How can i create my own database in unix shell? Not to create a database through shell to MySql, oracle etc, but to create a completely mine database system through shell. Please help me, give me directions, i'm desperate :( (1 Reply)
Discussion started by: vants
1 Replies

8. Shell Programming and Scripting

Creating my first Shell Script

I have an assignment in my programming class to write a shell script that will use command line parameters, display the # of parameters, display all parameters on the command line and display the parameters $0-$9. I understand some of the code (I will be using 'n' to represent the count through... (1 Reply)
Discussion started by: plmahan
1 Replies

9. Shell Programming and Scripting

help on creating shell script

Can some one smart here help I need to create a shell script that does this below using vi editor. decrypts a file (specified as an argument to the script) containing text which was encrypted using the ROT-13 algorithm. The decrypted text should be written to a new file leaving the input file... (1 Reply)
Discussion started by: master_6ez
1 Replies

10. Programming

Creating new shell in C

Hi, I am a student and I want to create a shell in C language. The shell must be able to take commands(with arguments) from the user and execute them and show the results. Any help or ideas or any suggestions would be greatly appreciated. Thanks (4 Replies)
Discussion started by: passat
4 Replies
Login or Register to Ask a Question