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
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 7 04-28-2009 03:08 AM
Sed , Replace a "variable text" inside of a statement jackn7 Shell Programming and Scripting 4 03-04-2008 03:40 PM
Running Windows "inside" a Linux-like OS? heliotos Linux 6 12-27-2007 12:38 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
"syntax error at line 21 :'done' unexpected." error message" ibroxy Shell Programming and Scripting 3 08-08-2007 07:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-25-2008
ricardo.ludwig ricardo.ludwig is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 10
"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 (permalink)  
Old 03-25-2008
redhead's Avatar
redhead redhead is offline
Registered User
  
 

Join Date: Feb 2002
Location: Denmark
Posts: 68
Quote:
Originally Posted by ricardo.ludwig View Post
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 (permalink)  
Old 03-25-2008
ricardo.ludwig ricardo.ludwig is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 10
Didnīt function

Hello Redhead, I tried your suggestion but the trouble is equal.
  #4 (permalink)  
Old 03-26-2008
redhead's Avatar
redhead redhead is offline
Registered User
  
 

Join Date: Feb 2002
Location: Denmark
Posts: 68
Quote:
Originally Posted by ricardo.ludwig View Post
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 04:57 AM..
  #5 (permalink)  
Old 03-28-2008
ricardo.ludwig ricardo.ludwig is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 10
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!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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