The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
'end of file' unexpected srisreeku Shell Programming and Scripting 1 04-28-2008 02:39 PM
end of file unexpected naveeng.81 Shell Programming and Scripting 1 03-11-2008 05:43 AM
unexpected end of file dineshr85 Shell Programming and Scripting 2 10-15-2007 02:47 AM
'end of file' unexpected abhijeetkul Shell Programming and Scripting 4 04-10-2006 06:42 AM
Gunzip : unexpected end of file Dolly UNIX for Dummies Questions & Answers 1 09-26-2002 05:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-11-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
'end of file' unexpected

HELP PLEASE!!

I am running this script, and i keep getting the error 'end of file' unexpected. I know that usually means parenthesis or whatever is out of place but i cant find anything!! I am new to scripting and i put some "print" staements in and it is not getting past the first IF statment i dont think. Here is the script. Thanks in advance

Code:
#!/bin/sh
echo "Please enter a station: \c"
read station
echo "Please enter the desired timestamp: \c"
read timestamp
cp PBLplot.pro $station/$timestamp
cd $station/$timestamp/
echo "Would you like to plot (1) 4panel with one var per map or (2) 4panel all vars per map: \c"
read choice
echo "$choice"
if "$choice" -eq 1
then
   echo "Please enter temperature variable (Skin, Tmpc, T10m, T20m, Dwpc, Ts01, Ts02): \c"
   read temperature
   echo "Please enter flux variable (Sens, Soil, Latn, Snof, Rdwn, Fupf, Sped): \c"
   read fluxvar
   echo "Please enter boundary layer variable (Hpbl, Fclc, Zlcl, Thbr, Shbr, Tdir, Tspd): \c"
   read bl
   echo "Please enter solar radiation variable (Sold, Solu, Atmr, Terr, Netr, Sumr, Bown): \c"
   read solarrad
   echo "Do you want to save this plot?: \c"
   read saveplot
   echo "Enter a file name (no extensions please): \c"
   read filename
   idl<<EOF
   .compile PBLplot.pro
   PBL
   $timestamp
   $choice
   $temperature
   $fluxvar
   $bl
   $solarrad
   $saveplot
   $filename
   exit
   EOF
elif "$choice" -eq 2
then
   echo "Do you want to save this plot?: \c"
   read saveplot
   echo "Enter a file name (no extensions please): \c"
   read filename
   idl<<EOF   
   .compile PBLplot.pro
   PBL
   $timestamp
   $choice
   $saveplot
   $filename
   exit
   EOF
fi
   
echo "continue" 
   
rm PBLplot.pro
#

Last edited by Franklin52; 10-11-2008 at 12:10 PM.. Reason: adding code tags
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-11-2008
Moderator
 

Join Date: Feb 2007
Posts: 3,547
The syntax of the if statement is not proper, replace the if and elif statement with:

Code:
if [ "$choice" -eq 1 ]

and

elif [ "$choice" -eq 2 ]
Beware of the spaces around the brackets.

Please place your code between code tags next time to improve readability. Select your code and click on the # symbol above the editing window.

Regards
Reply With Quote
  #3 (permalink)  
Old 10-11-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
Thank you for the quick response, you can see now that i have changed the syntax, but am still getting the same error....any other suggestions?

Code:
#!/bin/sh

echo "Please enter a station: \c"
read station
echo "Please enter the desired timestamp: \c"
read timestamp

cp PBLplot.pro $station/$timestamp
cd $station/$timestamp/

echo "Would you like to plot (1) 4panel with one var per map or (2) 4panel all vars per map: \c"
read choice
echo "$choice"

if [ "$choice" -eq 1 ]
then
   echo "Please enter temperature variable (Skin, Tmpc, T10m, T20m, Dwpc, Ts01, Ts02): \c"
   read temperature
   echo "Please enter flux variable (Sens, Soil, Latn, Snof, Rdwn, Fupf, Sped): \c"
   read fluxvar
   echo "Please enter boundary layer variable (Hpbl, Fclc, Zlcl, Thbr, Shbr, Tdir, Tspd): \c"
   read bl
   echo "Please enter solar radiation variable (Sold, Solu, Atmr, Terr, Netr, Sumr, Bown): \c"
   read solarrad
   echo "Do you want to save this plot?: \c"
   read saveplot
   echo "Enter a file name (no extensions please): \c"
   read filename
   idl<<EOF
   .compile PBLplot.pro
   PBL
   $timestamp
   $choice
   $temperature
   $fluxvar
   $bl
   $solarrad
   $saveplot
   $filename
   exit
   EOF
elif [ "$choice" -eq 2 ]
then
   echo "Do you want to save this plot?: \c"
   read saveplot
   echo "Enter a file name (no extensions please): \c"
   read filename
   idl<<EOF   
   .compile PBLplot.pro
   PBL
   $timestamp
   $choice
   $saveplot
   $filename
   exit
   EOF
fi
   
echo "continue" 
   
rm PBLplot.pro  
   
#
Reply With Quote
  #4 (permalink)  
Old 10-11-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,769
And [ is actually a symlink (or alias) to "test". So you could also do :

Code:
if test "$choice" -eq 1
Reply With Quote
  #5 (permalink)  
Old 10-11-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
after trying both of these suggestions it still yields the same error.
Reply With Quote
  #6 (permalink)  
Old 10-11-2008
Moderator
 

Join Date: Feb 2007
Posts: 3,547
Remove the spaces before EOF:

Code:
   idl<<EOF
   .compile PBLplot.pro
   PBL
   $timestamp
   $choice
   $temperature
   $fluxvar
   $bl
   $solarrad
   $saveplot
   $filename
   exit
EOF
Regards
Reply With Quote
  #7 (permalink)  
Old 10-11-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
You are my new best friend!!!!!!! Thank you so much. Have a great weekend!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 07:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66