LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2002, 09:42 AM   #1
saavik
Member
 
Registered: Nov 2001
Location: NRW, Germany
Distribution: SLES / FC/ OES / CentOS
Posts: 614

Rep: Reputation: 32
ok, i trie it once more


Well hello again!
I have now written the following skript:

-----------------------------------------------------------------
#!/bin/sh

echo "<HTML>"

while [1]; do
read ENTRY
if ["x$ENTRY"="x"];then
break;
fi
Name=`echo $ENTRY | awk '{ print $1}'`
Last=`echo $ENTRY | awk '{ print $2}'`
Dept=`echo $ENTRY | awk '{ print $3}'`
Phone=`echo $ENTRY | awk '{ print $4}'`
Email=`echo $ENTRY | awk '{ print $5}'`

echo "<p> Name: $Name $Last </p>"
echo "<p> Abteilung: $Dept </p>"
echo "<p> Telefon: $Phone </p>"

echo "</HTML>"
-----------------------------------------------------------------

the file testtelefon containes only the name and so
one by one!
i tried to execute it by typing:

-----------------------------------------------------------------
cat testtelefon | createhtml
-----------------------------------------------------------------

and than the pc sayed:

-----------------------------------------------------------------
<HTML>
/usr/bin/createhtml: line 21: syntax error: unexpected end of file
-----------------------------------------------------------------


1. what does that mean?
2. how can i tell the pc where to generate the file ?

thanx for each idea !
 
Old 04-17-2002, 10:01 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
The while loop is never closed of properly. It's missing the done. Try adding it right above the line echo "</HTML>"

And the first if statement looks a bit weird, try changing it to:

Code:
if [ -z "$ENTRY" ]
then
    break
fi
The output gets sent to stdout so if you want that in a file just do something like:

cat testtelefon | createhtml > newfile.html

Last edited by Mik; 04-17-2002 at 10:03 AM.
 
Old 04-17-2002, 10:07 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ok, a few things:

test: you'ev not got spaces around each [ and ]. [ IS a PROGRAM, not syntax, so MUST have spaces round it...

also you haven't closed your loop, which is what's causnig that line 21 error you've got.

you're using teh while loop very poorly. use "while read ENTRY" instead, and cut out that null strign checking crap.
 
Old 04-18-2002, 11:56 AM   #4
saavik
Member
 
Registered: Nov 2001
Location: NRW, Germany
Distribution: SLES / FC/ OES / CentOS
Posts: 614

Original Poster
Rep: Reputation: 32
Lightbulb wau super! Thank you

well ok i think this should help!
I will trie it tomorrow and write how it works!
bye
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration