Output is not Accurate

list db directory |grep alias |awk '{print "connect to ",$4}'

In a shell script the below line should display output as below

connect to <DATABASENAME>

but its throwing error like

 
 Syntax Error The source line is 1.
 The error context is
                {print connect to, >>>  } <<<
 awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.

Can somebody help to rectify this ? Is there any syntax error ?

It looks good interms of grep & awk. What does "list db directory " ?

Small suggestion,

list db directory |awk '/alias/ {print "connect to ",$4}'

instead of

list db directory |grep alias |awk '{print "connect to ",$4}'

Out put of list db directory will come like this for n no.of database entries.

 
Database 1 entry:
 Database alias                       = XXXXX
 Database name                        = XXXXX

Tested ur code seperatly not with script ..Its showing o/p properly.

 
 list db directory |awk '/alias/ {print "connect to ",$4}'
connect to  AAAAAA
connect to  BBBBB
connect to  CCCCCC
connect to  DDDDD

But when add the same line to my script and ran its throwing the same error which pasted initially.

I am not sure.

 awk '/alias/ {print "connect to",$4}' INPUT

output:

connect to XXXXX
cat INPUT
Database 1 entry:
 Database alias                       = XXXXX
 Database name                        = XXXXX

You have truncated the script as well as the input. Please post more context.

Below is hte script which i m trying to for my requirement.If we run the highlighted part individually on database its running file and production accurate o/p
Expected

connect to XXXX
connect to YYYY
connect to ZZZ.

for line in `cat 1.txt`
do
echo @@@@@@@ YOU ARE IN HOST ${line} @@@@@@@@@ >> CRON-List
ssh -o ConnectTimeout=10 ${line} "ls '/home/prods/db2' |grep "^U"|sort|uniq" > I-List
    for line1 in `cat I-List`
     do
 typeset -l line1
instance=$line1
     ssh -o ConnectTimeout=10 ${line} "ksh -s <<EOF
       sudo suudb $instance
echo  $instance;>>file.out
db2 list db directory |grep alias |awk '{print "connect to " $4}'>>file.tmp"
done

That's what I thought: an unmatched double quote in front of ksh -s <<EOF and/or a missing EOF token.

You mean

 
"ksh -s" <<EOF

THis should work ?

Try it. And don't forget the EOF delimiter.