Create script within a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create script within a script
# 1  
Old 05-24-2012
Create script within a script

Hi,

I am having problem in creating a tcsh script that will create a bsh script.

My code is as the following

Code:
#! /bin/tcsh -f
set 
ITER = iter1
 
 
mkdir attr
 
cd attr
 
 
echo ITER= | gawk -v "iter=${ITER}" '{print $0iter}' >! attr_cps.sh
 
cat <<EOF >> attr_cps.sh
#Change the parameters if necessary
 
tol=100.0
min_sig=0.0
max_dip=85.0
 
 
LINEA=`\fgrep LINEA= ../../*par | cut -d "=" -f2 | \awk '{print $1;}'`
LINE=`\fgrep LINEA= ../../*par | cut -d "=" -f3`
 
echo combine attributes ...
echo LINEA=$LINEA LINE=$LINE 
 
rm L*vs
 
attrSti.g64 \
-G_FILE ../../L$LINE.geom \
-INPUT_FILE ../rcd_stick/L${LINE}_${ITER}_4_deci_rcd.stick \
-OUTPUT_FILE L${LINE}_${ITER}_rcd.vs \
-MINIMUM_SIGMA ${min_sig} \
EOF

and the error message I got are as

Code:
fgrep: No match.
fgrep: No match.
LINEA: Undefined variable.

Could anyone out there point me a solution for this problem? Thanks so
much.

Bullcreek


Moderator's Comments:
Mod Comment Please use code tags, thanks!

Last edited by zaxxon; 05-24-2012 at 05:45 AM.. Reason: code tags
# 2  
Old 09-19-2012
Re: Create script within a script

You need to wrap EOF in quotes ("EOF")

Try this:

Code:
#! /bin/tcsh -f
set 
ITER = iter1
 
 
mkdir attr
 
cd attr
 
 
echo ITER= | gawk -v "iter=${ITER}" '{print $0iter}' >! attr_cps.sh
 
cat <<"EOF" >> attr_cps.sh
#Change the parameters if necessary
 
tol=100.0
min_sig=0.0
max_dip=85.0
 
 
LINEA=`\fgrep LINEA= ../../*par | cut -d "=" -f2 | \awk '{print $1;}'`
LINE=`\fgrep LINEA= ../../*par | cut -d "=" -f3`
 
echo combine attributes ...
echo LINEA=$LINEA LINE=$LINE 
 
rm L*vs
 
attrSti.g64 \
-G_FILE ../../L$LINE.geom \
-INPUT_FILE ../rcd_stick/L${LINE}_${ITER}_4_deci_rcd.stick \
-OUTPUT_FILE L${LINE}_${ITER}_rcd.vs \
-MINIMUM_SIGMA ${min_sig} \
EOF

# 3  
Old 09-19-2012
Quote:
Originally Posted by raravena
You need to wrap EOF in quotes ("EOF")
Yes. Without that, the shell will interpret variables and backticks inside it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

Script used to create another script

Hi guys . I want to create a script for POST INSTALLATION for new machines being deployed in my Data Center. I want to create a script post_install.sh that further creates a new script(s) that are essential for system connectivity e.g. mails etc to other systems. How can I achieve this ? ... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

3. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

4. Shell Programming and Scripting

Bash: How can a script create a script?

I need to write a bash script that will generate another bash script. Furthermore, the child script is required to be hard-coded into the parent script. The parent script is not allowed to import the child script from an external file at run time. If you have a better solution than the... (3 Replies)
Discussion started by: LessNux
3 Replies

5. Shell Programming and Scripting

Help Create dynamic ksh script from a script

I am currently running 2 scripts to gather data for a 3rd script and would like to combine the 2 scripts into one. Having issues with the final output format. Note cannot post URL so replaced the http stuff with (name) in the examples All scripts contain #!/bin/ksh OS = Red Hat Enterprise... (0 Replies)
Discussion started by: pcpinkerton
0 Replies

6. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

7. Shell Programming and Scripting

Script that also create a script, how can i save it?

say i have a script that says cat > resultofsample.sh #!/bin/bash codes but how can i exit it from here and save it? (8 Replies)
Discussion started by: garfish
8 Replies

8. Shell Programming and Scripting

Need help to create a script...

Hi, Am very new to scripting and yet to start learning... I need a help to create a script which should run in my unix boxes to acheive the following... 1. Need to copy the hosts file and save it as hostDDMMYYY 2. Should comment a line which matches the string cmpd 3. Should add a new... (5 Replies)
Discussion started by: sarav
5 Replies

9. UNIX for Dummies Questions & Answers

Create a script

How to I put my find command string into a script. It is currently to long to be entered manually at command line. for FNAME in `find /unixsxxx/interface/x.x/xxxxxx -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh' \) -exec grep -il xxx.xxx.xxx.xxx {} \;`; do C=`grep -c... (1 Reply)
Discussion started by: TimHortons
1 Replies

10. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question