Jump to content

small bugged script

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
bogdan32x

bogdan32x

    Newbie

  • Members
  • Pip
  • 2 posts
it's supposed to be an XML generator but it gives this ackward error...i would appreciate any help

#!/bin/bash

header=$1;

file1=$2;

file2=$3;

footer=$4;

cat $header

cat $file1

cat $file2

cat $footer

cat $header > pair_xml.xml


fil=`cat $file1 | tr '\n' ' '`

fil2=`cat $file2 | tr '\n' ' '`




  for i in 0 1 2 3

  do

    #if vv && vs

    # then

    printf "<url>" >> pair_xml.xml

    printf "<doc1>" printf "http://%s" $fil[$i] printf "</doc1>" >> pair_xml.xml

    printf "<doc2>" printf "http://%s" $fil2[$i] printf "</doc2>" >> pair_xml.xml

	printf "</url>" >> pair_xml.xml

	printf "<raw>" >> pair_xml.xml

	printf "<doc1>" printf "%s" $fil[$i] printf "</doc1>" >> pair_xml.xml

    printf "<doc2>" printf "%s" $fil2[$i] printf "</doc2>" >> pair_xml.xml

	printf "</raw>" >> pair_xml.xml

# else

#   echo "Error"

#   fi

#   break

   done



#cat -f $footer

cat $footer >> pair_xml.xml

the error i get is

line 18: syntax error near unexpected token `do
line 18: ` do

Edited by bogdan32x, 15 July 2010 - 04:17 AM.


#2
bogdan32x

bogdan32x

    Newbie

  • Members
  • Pip
  • 2 posts
never mind figured it out in the meantime... but if anyone else has problems on similar scripts i'm glad to help them

#3
konsolebox

konsolebox

    Newbie

  • Members
  • Pip
  • 4 posts
It's not a good practice to leave variables placed in the open. It's always best to place them around quotes ("). You can also read this for reference: BashPitfalls - Greg's Wiki