Error in scripting ftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in scripting ftp
# 1  
Old 06-07-2005
Error in scripting ftp

Good Morning,

I just would like to know what is wrong with my script. I am trying to use a for loop on my ftp command but the part that pipes the ftp information is reported in unix as error. Here's my script :

#!/bin/ksh
# other parts of the script here....

# get all ORD* files created and then ftp it to the other server...

cd $PRODATA
ORDDOWNLD=`ls ORD????.DLD`
# test data - ORDDOWNLD='ORD8705.DLD ORD8706.DLD ORD8707.DLD'

# then delete e_downso.txt
# Above file is the source of records for ORD files. Once #our system did not find the file "e_downso.txt", it will #generate another ORD file, which is ok because it will not #be part of the list....

# I could also add a logic to rename the ORD* files in the #list variable so that other process running this same script
# will not pick this file again.....



export ORDDOWNLD

for i in $ORDDOWNLD
do
# transfer ORD files one by one......
ftp -n -v wms > josephtest.log <<- !
user test test^M
cd done
put $i
get $i J$i
quit^M
!
# compare if ORD in WMS is equal to what is in GLOVIA...
diff $i J$i
# then test if there is difference,,,if none, then delete $i.....

# else send an email to helpdesk to inform users that part of $i was not copied to WMS...
done

#=================end of script=================================


After running above script, I am getting the following error :

/glo71sw/716/devl/userdata/scripts --> ./josephtest.k>
./josephtest.ksh[7]: syntax error at line 12 : `<<' unmatched
/glo71sw/716/devl/userdata/scripts -->


Please advise. Basically, our goal is to make sure the ORD file we ftp to the other server is the same copy as in our source server. The source of the ORD file is getting updated by many users that is why after getting the list of ORD* files,

Thank you very much!

Joseph
# 2  
Old 06-07-2005
Joseph,

the "<<- !" in line 12 is basically the start of what gets sent to the ftp log. Right below the "quit" line you should have the terminating string to say when to stop sending the output to the ftp log. You have a single "!" instead of a "- !" that you have at line 12.

Scripts at my company usually use a *** as a starting and stopping point.

ftp -nv >> ftplog.log <<***
open user
get
put
quit
***

I do not think it matters what is used as long as it matches the string at the start.

;

Last edited by SemiOfCol; 06-07-2005 at 01:09 PM..
# 3  
Old 06-07-2005
Thanks SemiOfCol!

I will try it out...I thought the "-" is part of the "<<" command....I will replace the "!" with the EOF.

Joseph
# 4  
Old 06-07-2005
I am still getting the same error even after replacing "<<- !" and "!" with "<<EOF" and "EOF". Help!

Thanks!

Joseph
# 5  
Old 06-07-2005
remove '^M' from your script - use dos2unix [if you have one]
[or vi/sed]
# 6  
Old 06-08-2005
Thanks!

I tried removing the "^M" but I am still getting the error.

Is it possible to run "ftp" inside a for loop like what I am doing? Please help..
Thanks!

Joseph
# 7  
Old 06-08-2005
Quote:
Originally Posted by negixx
Thanks!

I tried removing the "^M" but I am still getting the error.

Is it possible to run "ftp" inside a for loop like what I am doing? Please help..
Thanks!

Joseph
pls post once again the code snippet exactly as it is and what you're seeing.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

FTP scripting issue

I dont have enough bits to post in emergency, but I have an urgent FTP issue. A client of ours wants us to pull files from his server onto our server at which point we can process it. I ask a friend what to do, but I was just give the things to do, not how to do it. I havent written a Unix... (4 Replies)
Discussion started by: MJCreations
4 Replies

2. Shell Programming and Scripting

Scripting with FTP Process

Hi Guys, Good day ULF! I have a general "auto-ftp" code which looks something like this: #!/bin/sh cd $1 ftp -v -n $2 << EOF user $3 $4 prompt cd $5 bin mput $6 quit EOF This works pretty well, but I'm thinking of how can I make a code by maybe including on this code, for... (5 Replies)
Discussion started by: rymnd_12345
5 Replies

3. Shell Programming and Scripting

Need FTP scripting

Hi, Please can you tell me the script to transfer file from server A to Server B (1 Reply)
Discussion started by: e1994264
1 Replies

4. Shell Programming and Scripting

FTP scripting Help

Hi, I'm trying to do an FTP script that will read from a list of files and send only the files in that list. Would this work? Does anyone have anything simpler. ftp -nv <<EOF open server user username password get $(nawk -F_ -f bbb.awk Filelisting.txt) EOF (5 Replies)
Discussion started by: bbbngowc
5 Replies

5. Shell Programming and Scripting

Shell scripting - FTP

Can some one help with script to track ftp logins on AIX server.. (1 Reply)
Discussion started by: ddk2oo5
1 Replies

6. Shell Programming and Scripting

Ftp scripting question

Hi guys, I'm trying to create an ftp script that will read in a value from input, then search for files with the input value, and then ftp the files.. So far I've got my read answer set up, and it'll ls -lrt out my files with the value read answer var I given it... My question is, what... (14 Replies)
Discussion started by: Jazmania
14 Replies

7. Shell Programming and Scripting

FTP scripting

Hello, I'm sure this is an easy one for you UNIX pros. I would like to create and and automated an FTP process. The script should do this: 1. Log into a remote system 2. change to a specified directory 3. copy local files to the remote system 4. quit ftp 5. wait until the next schedule ... (7 Replies)
Discussion started by: bbbngowc
7 Replies

8. Answers to Frequently Asked Questions

Automate FTP / Scripting FTP Transfers

One of our most frequent questions is how to automate ftp transfers. There are several approaches. Since I'm writing this post, we will start with my favorite technique. :) In Automated FTP task I present a simple example of my ksh co-process technique. And note that later in this thread I... (0 Replies)
Discussion started by: Perderabo
0 Replies

9. Shell Programming and Scripting

scripting a ftp process

I am trying to automate a process in one of two ways: 1) ftp .txt files from a unix server to a Windows 2000 server. I want to do this in a script. Can I supply the login and password to the Windows server inside the script? 2) I tried this and failed: sftp .txt files from the unix server to... (2 Replies)
Discussion started by: gbernard
2 Replies

10. UNIX for Dummies Questions & Answers

Telnet FTP scripting

Hi quick question from a unix newbie Working on a project to get me using unix, the point of this project is to find a printer on the network check for jobs in the printer if the printer has no jobs do nothing if the printer has jobs then check the status for errors and e-mail the user. This... (2 Replies)
Discussion started by: w33man
2 Replies
Login or Register to Ask a Question