"unexpected end of file" when Iīm use EOF inside block if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting "unexpected end of file" when Iīm use EOF inside block if
# 1  
Old 03-25-2008
"unexpected end of file" when Iīm use EOF inside block if

I have a trouble in my script when i use EOF inside block if.
If i use EOF whitout block if I donīt have problem.
Guys any ideas?
Sorry for my terrible English.

#!/bin/sh
set -xv

HOST='ftp.fiction.com.br'
USER='fictionuser'
PASS='fictionpass'
FILE='ftpteste.txt'
busca=`find ftpteste.txt`;
if [ "$busca" = "$FILE" ]; then
echo Okay File it exists
ftp -v -n $HOST <<-EOF
quote USER $USER
quote PASS $PASS
put $FILE
quit
EOF
else
echo Donīt have file in the folder
fi
exit
# 2  
Old 03-25-2008
Quote:
Originally Posted by ricardo.ludwig
If i use EOF whitout block if I donīt have problem.
If I understand you correct here, it's the term EOF which is choking your if/else runthrough, have you tried calling it something else, ie:
Code:
#!/bin/sh
set -xv

HOST='ftp.fiction.com.br'
USER='fictionuser'
PASS='fictionpass'
FILE='ftpteste.txt'
busca=`find ftpteste.txt`;
if [ "$busca" = "$FILE" ]; then
  echo Okay File it exists
  ftp -v -n $HOST <<-EOC
    quote USER $USER
    quote PASS $PASS
    put $FILE
    quit
  EOC
else
  echo Donīt have file in the folder
fi
exit

# 3  
Old 03-25-2008
Didnīt function

Hello Redhead, I tried your suggestion but the trouble is equal.
# 4  
Old 03-26-2008
Quote:
Originally Posted by ricardo.ludwig
Hello Redhead, I tried your suggestion but the trouble is equal.
Then on a different approach, have you tried with ncftpput forinstance ?
Code:
#!bin/sh
set -xv

HOST='ftp.fiction.com.br'
USER='fictionuser'
PASS='fictionpass'
FILE='ftpteste.txt'
if [ -f $FILE ]; then
  echo "OK file exists"
  if [ -r $FILE ]; then
    echo "OK file is readable"
    ncftpput -u $USER -p $PASS $HOST . $FILE 2>&1 /dev/null
    if [ $? -ne 0 ]; then
      echo "Error uploading file"
    else
      echo "OK file uploadet"
    fi
  else
    echo "Error file is unreadable"
  fi
else
  echo "Error file does not exist"
fi


Last edited by redhead; 03-26-2008 at 05:57 AM..
# 5  
Old 03-28-2008
I obtain the solution

Hi,

I obtain the solution for this trouble, I remove the white space before
ftp -v -n $HOST <<-EOF and
EOF

Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error: "Syntax error; unexpected end of file"

Hello all, I am running a script to generate a report and mail it to an email address. When I am trying to validate whether the file is a 0 kb file, I am getting the below error. Error: "Syntax error; unexpected end of file" Any suggestions please? Code: #!/bin/sh .... (1 Reply)
Discussion started by: Pradeep_Raj
1 Replies

2. BSD

Keep getting error "-bash: ./.profile_z2: line 52: syntax error: unexpected end of file"

#!/bin/bash #-------------------------------------------------------- # Setup prompt # Author Zeeshan Mirza # Data: 06-08-2017 #-------------------------------------------------------- if then . ./.profile_custom_pre fi umask 022 set -o vi export EDITOR=vi export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies

3. SCO

"Unexpected EOF within #IF, #ifdef or #ifndef" error when rebuilding / relinking SCO OpenServer 5

Hi, I am a new Unix Guru with very little experience but have the task of P2Ving an old HP Proliant ML370 G5 server to VMware ESX 4.1 or ESXi 5.5. System seems to boots fine but when trying to remove HP software, configure TCP/IP or a driver, I am receiving: -------- ... (7 Replies)
Discussion started by: dj_Italian
7 Replies

4. Shell Programming and Scripting

Please identify "unexpected end of file" bug

This is a script I got off the web for transferring Safari's "reading list" to the Pocket app. I ran it in terminal with the command bash exportsafarireadinglist.sh and got syntax error: unexpected end of file. Thanks for any help! The code: #!/bin/bash # Script to export Safari's reading... (2 Replies)
Discussion started by: kdog126
2 Replies

5. Shell Programming and Scripting

Error"syntax error at line 15: `end of file' unexpected"

While i m running below code, it is giving me the error"syntax error at line 15: `end of file' unexpected". Pls let me know what is wrong here..i tried many ways, but no luck dbSID="SWQE" usrname="apps" password="Wrgthrk3" count=0 while do sqlplus $usrname/$password@$dbSID... (5 Replies)
Discussion started by: millan
5 Replies

6. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

7. Shell Programming and Scripting

Help with error "syntax error: unexpected end of file"

Hi Techies, can anyone please debug the following Script and let me know what is going wrong here. im getting the following error #!/usr/bin/bash # ############################################################################################## # # Variables # #... (2 Replies)
Discussion started by: mahi_mayu069
2 Replies

8. Shell Programming and Scripting

"Unexpected end of file" on a very simple script!!!

Well, this is a very crazy issue, and I'm scratching my head to find a solution. This is a simple code to tranfer a file, in my main script I need to add a conditional statement (IF/THEN) like the below example: #!/bin/bash if ; then ftp -inv "192.168.1.10" << EOFTP user... (8 Replies)
Discussion started by: Lord Spectre
8 Replies

9. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

I have a piece of Linux script. It tells me some syntax error. I couldn't find it. Please help me to identify them. Thanks. The code looks like this: export ORACLE_SID=MYDB export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID` export check_arch=`sqlplus -s << EOF / as sysdba... (7 Replies)
Discussion started by: duke0001
7 Replies

10. UNIX for Dummies Questions & Answers

"unexpected end of file"

%%%%% (9 Replies)
Discussion started by: lucasvs
9 Replies
Login or Register to Ask a Question