[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

Shell Program Error undefined Variable?

Following is the script

#!/bin/csh  

#*+P
#$Header: $
#
#
#$Log: $
#
#-P*#


#created by tom mclaughlin 01/13/00

#create_three_tables.csh--creates three tables needed in Sybase for join
#statement in Volume Definition File process

echo "Enter the Sybase database where your want"
echo "to create the tables followed by a carriage return"
read database

echo "Enter the center followed by a carriage return."
read center

echo "Enter your sybase username followed by a carriage return."
read username

echo "Enter your sybase password followed by a carriage return."
read password

##input center into sql statements
sed -f "s/CENTER/$center/g" /home/tmclaugh/test/airspace.sql >! /home/tmclaugh/test/airspace.sql.tmp            
sed -f "s/CENTER/$center/g" /home/tmclaugh/test/fpa.sql >! /home/tmclaugh/test/fpa.sql.tmp
sed -f "s/CENTER/$center/g" /home/tmclaugh/test/node_latlng.sql >! /home/tmclaugh/test/node_latlng.sql.tmp

#create tables

echo "creating airspace table"

isql -D $database -U $username -P $password < /home/tmclaugh/test/airspace.sql.tmp

echo "done creating airspace table"

#create fpa table

echo "creating fpa table"

isql -D $database -U $username -P $password < /home/tmclaugh/test/fpa.sql.tmp

echo "done creating fpa table"

#create node_latlng table

echo "creating node_latlng table"

      isql -D $database -U $username -P $password < /home/tmclaugh/test/node_latlng.sql.tmp

echo "done creating node_latlong table"


echo "all three tables should be in the database you selected in Sybase"


The error I keep getting says that center is an undefined variable?


0
tomatocans
Asked:
tomatocans
1 Solution
 
expert99121199Commented:
change

#!/bin/csh

to

#!/bin/sh


Also remove the "!" character from the output redirects.

For example,

sed -f "s/CENTER/$center/g" /home/tmclaugh/test/fpa.sql >! /home/tmclaugh/test/fpa.sql.tmp

should be

sed -f "s/CENTER/$center/g" /home/tmclaugh/test/fpa.sql > /home/tmclaugh/test/fpa.sql.tmp

"read variable" is not  C shell syntax.

it looks like a Bourne/Korn script, not a C shell  script.
0
 
tomatocansAuthor Commented:
Thank you very much.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now