Problem with here doc operator in FTP script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with here doc operator in FTP script
# 1  
Old 07-03-2008
Problem with here doc operator in FTP script

Hello folks,
I am facing a problem with the following korn shell script snippet:
ftp -n -i -v <<EOF
print -p open $CURR_HOST
print -p user $USER $PASSWD
print -p binary
print -p cd /mydir/subdir/datadir
print -p get $FILENAME
print -p bye

EOF
exit
It gives me the following error
./EDW_FTP.sh[27]: syntax error at line 41 : `<<' unmatched
This FTP code snippet is inside a for loop which goes like this:
for ctr in ${hosts}
where hosts is an array.

I am running it in a Solaris UNIX environment.
Thanks.
# 2  
Old 07-03-2008
Is the code indented in the actual script, by any chance? If so, try putting the "EOF" in the leftmost column (i.e. no white space before it).

Also, the print -p commands are unnecessary, as the shell reads the here doc in as it is.
# 3  
Old 07-03-2008
Yes the code is indented ... so what should the line containing the EOF look like?
# 4  
Old 07-03-2008
Code:
        ftp -n -i -v <<EOF
                open $CURR_HOST
                user $USER $PASSWD
                binary
                cd /mydir/subdir/datadir
                get $FILENAME
                bye
EOF
        exit

In some shells if you use the <<- EOF operator (which strips white space off the beginning of the input lines to allow you to indent) it will recognise the end-of-here-document marker whether it is indented or not.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem with pipe operator

hi i am having issues with extra pipe. i have a data file and i need to remove the extra pipe in the(example 4th and 7thline) in datafile. there are many other line and filed like this which i need to remove from files. The sample data is below: 270 31|455004|24/03/2010|0001235|72 271... (3 Replies)
Discussion started by: abhi_n123
3 Replies

2. Shell Programming and Scripting

problem while using FTP in shell script

Hi all, I am having problem while using FTP in shell script.I am downloading a file from other machine.Part of file name is known to me(in red) 20100114123814.portin.virginsubs.extract What i am doing is trying to get the file using get command with wild card "*" (see below) but it fails... (1 Reply)
Discussion started by: vinoo128
1 Replies

3. UNIX for Dummies Questions & Answers

Problem unary operator expected

I get the following error ./get_NE05: line 42: while do echo ${STRING_NAME} J=1 if ; then EXT=0$I else EXT=$I fi while do echo $I-$J #calculating last occurrence OCCURRENCE=`grep -io "${STRING_NAME}"... (3 Replies)
Discussion started by: f_o_555
3 Replies

4. Shell Programming and Scripting

Problem when extracting the title of HTML doc

Dear all. I need to extract the title (text between <title> and </title>) of a set of HTML documents. I've found a command that makes the work of extracting the text, but it does not always work. It works with the next example: cat a.txt htmltext<title>This is a HTML... (2 Replies)
Discussion started by: i007
2 Replies

5. Solaris

FTP Script Problem

Hi Everybody, I am working on FTP Script (i,e Parser.sh,Upload.sh) and the contents of the same are mentioned below .., #!/bin/bash if ; then echo "Usage ./Parser.sh IP USERNAME PASSWORD SOURCE FILENAME DESTINATION where IP ------------- IP address of remote... (0 Replies)
Discussion started by: prasanth_babu
0 Replies

6. Shell Programming and Scripting

Having a problem with a FTP Script using perl

Hello All, I have a problem that has me stumped. I am using perl to do some ftp'ing of files. I have the script in place on another environment that is functioning flawlessly. But after tweaking it to the new environment I can't get it to function. I have a search string that searches for... (6 Replies)
Discussion started by: scottzx7rr
6 Replies

7. Shell Programming and Scripting

FTP script and problem

We have a script where we're trying to ftp to an outside ftp server, but it keeps failing with the error: 421 Service not available, remote server has closed connection if we ftp <server> and manually enter the username and password from the Unix box it's just fine. But when we try to... (1 Reply)
Discussion started by: lawadm1
1 Replies

8. Shell Programming and Scripting

FTP Script Problem

Hi, Firstly, I would like to admit that I am a scripting newb. :) Now, to my question: I am writing a script that FTPs a bunch of logs from one server to another, it will be scheduled in Cron to run every 20 minutes. Currently, the file transfer part of the script is fine. However,... (2 Replies)
Discussion started by: reebz
2 Replies

9. Programming

Problem about c++ new operator

#include <iostream.h> class test { private: int i; public: inline test(int m) { i = m; } inline int get_i() { return i; } }; int main() { test * a = new test(2); (3 Replies)
Discussion started by: xbjxbj
3 Replies

10. UNIX for Advanced & Expert Users

problem with ftp script...please help

Hi, I'm writing an ftp script that is trying to connect to a remote NT box. Here is my script: ftp -i ipaddress user username password ascii cd db_Backup lcd /home/dB_backups put *.sql bye When I run this script I get the following error: 500 'AUTH GSSAPI': command not... (2 Replies)
Discussion started by: vancouver_joe
2 Replies
Login or Register to Ask a Question