end of file error bash ftp script

Hello kind programmers :slight_smile:

I am a newbie and running into an error "line 28: syntax error: unexpected end of file" on the script shown below. Any help would be greatly appreciated. Thanks!

#! /bin/bash

if ($#argv <3) then 
 echo 'Usage get_modis_snow [yyyy] [mm] [dd] [tile]'
 echo 'ftp script for MYD10A2 8-day, 500-m snow'
 echo 'example: get_modis_snow 2006 01 01 h08v05' 
 exit
endif

set yyyy="$1"
set mm="$2"
set dd="$3"
set tile="$4"

target=/desired_folder/

USER="anonymous"
PASS="email_address"

ftp -inv n4ftl01u.ecs.nasa.gov<<ENDFTP
user $USER $PASS
cd /SAN/MOSA/MYD10A2.005/$yyyy.$mm.$dd
put MYD10A2.A$yyyy.$tile.?????????????.hdf>>$target
bye
ENDFTP

exit 0

Thanks in advance!
Cheney

Your mixing csh keywords like endif with bash keywords which should be fi in your case. Plus your using set instead of yyyy="$1" etc...

The script might actually work just by changing the shell to csh in the top line:

 
#!/bin/csh

Thank you simusphere :slight_smile: Changing to csh worked. I appreciate your help!!!