Ftp code problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ftp code problem
# 1  
Old 06-22-2004
Ftp code problem

Hello

I am trying to write a script that sends files via ftp from one server to another, i am using AIX 5.1. and bash shell to write my code.

I get an error when trying to run the following lines of code

ftp -n aptsbou01 <<!
user $username $password
binary
put $file
bye
!

I get the following error
ftptest.sh[7]: 0403-057 Syntax error at line 13 : `<' is not matched.

where line 13 is the first line in the code snippet above.

But i believe that is the correct syntax for this statement. I am unable to proceed further due to this error.

I would appreciate if anybody could help me in resolving this.

Thanks in advance
Swaraj
# 2  
Old 06-22-2004
Network

Hello

Doesnt anybody have a solution for this one, I am in urgent need of this please if anybody knows or can guide me to a link where i can find a solution that would be great.

Thanks
SwarajSmilie
# 3  
Old 06-22-2004
Well, I've got an ftp server running on one of my systems, and
Code:
 
ftp -n localhost <<!
blah 
.
.
.
blah
!

Works fine for me in a bash script.

Can you post your *complete* script?

Actually, I think I know where your problem may be. Where you close the here document with "!", if it isn't in column 1 of the file (i.e. NO leading whitespace), then the here document will not be properly terminated.

Peace
ZB

Last edited by zazzybob; 06-22-2004 at 07:39 PM..
# 4  
Old 06-22-2004
Thanks a lot for responding

Here is my complete code

# search for files with .txt extension
(ls -la *.txt | awk '{print $0, ","; }') > filelist.txt
chmod a+x filelist.txt
filenamelist=$(cat filelist.txt | awk '{print $9;}')
#server = "aptsbou01"
for file in $filenamelist; do
filename=${file##/*/}
if [[ -f $filename ]] ; then
echo $file
echo "Now transmitting each file via ftp"
echo "Connecting to ftp on another server"
ftp -n aptsbou01 <<!
user kankipas nodalMB8
binary
put $file
bye
!
fi
done
#echO $(#filenamelist[*])

Thanks
Swaraj
# 5  
Old 06-22-2004
Hi ZB

I actually modified my script so that the code for the ftp session starts from column 1 and it worked.

Thanks a lot for the help.

Swaraj
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

ftp problem?

Dear All I cannot ftp to my RedHat server from MS Windows machine ,but ping and telnet are ok. I checked as the following : #chkconfig tftp on #setup After enabling tftp service, still the ftp is not ok but ping & telnet are ok. Can you please help me? Thank you (8 Replies)
Discussion started by: hadimotamedi
8 Replies

2. Shell Programming and Scripting

problem with ftp

hi there here is my problem i have a shell that copy files from unix to a shared linux samba (with rcp) i will change my linux machine with a windows one and saw rcp didnt work anymore ... so i tried ftp and saw it worked with these following commands ftp -niv <<fin open 192.9.200.105 user... (3 Replies)
Discussion started by: bzh35
3 Replies

3. Shell Programming and Scripting

FTP Problem

Hello experts, I've got the following script that is supposed to FTP a file to another box. #!/usr/bin/ksh while read line do HOST=`echo "$line" | cut -d" " -f1` USER=`echo "$line" | cut -d" " -f2` PASSWD=`echo "$line" | cut -d" " -f3` PATH=`echo "$line" | cut -d" " -f4` done <... (5 Replies)
Discussion started by: King Nothing
5 Replies

4. UNIX for Advanced & Expert Users

ftp problem

Dear friends, i am trying to login in to remote ftp type unix the error illegal ERPT command is coming. what is the solution. the output: Name (ftpser.xxxxx.gov.in:imdps): hmts 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary... (1 Reply)
Discussion started by: rajan_ka1
1 Replies

5. Shell Programming and Scripting

FTP Problem

Hi, I'm currently stuck in this ftp problem. Normally I just type ftp at the command line, but now I have to implement it in a code. Basically I have to transfer a .txt file from a server, let's say hkhpdv13 in the folder of /home/sap/ftp to another server hkhpdv15 in the folder... (2 Replies)
Discussion started by: kdyzsa
2 Replies

6. Solaris

FTP problem

Hi Guys, Got problem when I tried to get files from Solaris server to my PC. The connection transfer was using FTP and the connection was made from the solaris server to my PC. Here's what happened when the file transfer being made: # ftp 10.192.23.230 Connected to 10.192.23.230. 220... (9 Replies)
Discussion started by: raskita
9 Replies

7. Solaris

FTP problem

Hi everyone , have a nice day i have 4 Sun Machines at my work , i have made few scripts which copies data from 3 of them to first one , then i have made another program in visual basic , which FTP to this first machine ( after every minute ) , get that data file and displays it on screen , i... (2 Replies)
Discussion started by: Dastard
2 Replies

8. UNIX for Dummies Questions & Answers

FTP problem. please help

can someone tell me how I can deal with a problem am having concerning users that are faliing to use one of the shells specified in the /etc/shells file. as a result, am told, these users are bound fail to connect via FTP. i know i goto check the /etc/shells file on the target host but what... (5 Replies)
Discussion started by: TRUEST
5 Replies

9. UNIX Desktop Questions & Answers

ftp problem

I use FTP in a shell script to transfer the files to a remote server. Sometimes the program hangs without returning any errors after the command ftp server_name How do you detect from within the shell that something is wrong? How do you trap the errors returned by ftp command? Any help... (3 Replies)
Discussion started by: marusia
3 Replies

10. UNIX for Dummies Questions & Answers

ftp problem

Hi I am accessing ftp server remotely, but i am getting the following error ie connection timed out what could be the reason? Thanks (1 Reply)
Discussion started by: bache_gowda
1 Replies
Login or Register to Ask a Question