If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > FTP script problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-08-04, 18:54
adokli adokli is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
FTP script problem

FTP script problem
I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

Please tell me what I am doing wrong here.

#!/bin/ksh
userString="brsgadmin"
pswdString="brsg6906"
#ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
ifmsfile="COPY_DB_STATUS.DAT"
ftp -in ba0470.optus.com.au <<-END_FTP
user $userString $pswdString
get ${ifmsfile}
quit
-END_FTP

echo "file transfer has completed"
date
Reply With Quote
  #2 (permalink)  
Old 01-09-04, 02:21
xadoxadox xadoxadox is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
well you could try to put the last two lines:the one with the message and the one with the date before quit
Reply With Quote
  #3 (permalink)  
Old 01-16-04, 15:45
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Re: FTP script problem

I would suggest breaking the FTP portion into another ksh file you call from this one. That way you can truly tell whether the transfer completed successfully. Your script as it is assume the transfer will work all the time successfully. Example:

echo "**** Transfering file ****"
ksh push.ftp > /tmp/push_ftp.$$
if (grep -c "Transfer complete" /tmp/dnb_ftp.$$ > /dev/null);
then
echo "**** Transfer Complete ***"
else
echo "**** Transfer ERROR ****"
fi

Quote:
Originally posted by adokli
FTP script problem
I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

Please tell me what I am doing wrong here.

#!/bin/ksh
userString="brsgadmin"
pswdString="brsg6906"
#ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
ifmsfile="COPY_DB_STATUS.DAT"
ftp -in ba0470.optus.com.au <<-END_FTP
user $userString $pswdString
get ${ifmsfile}
quit
-END_FTP

echo "file transfer has completed"
date
Reply With Quote
  #4 (permalink)  
Old 01-17-04, 11:43
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
If you create a file named .netrc in your $HOME directory with the permissions 400 you dont need USER and PASS for ftp.
This is only a tip for using ftp.
__________________
Greetings from germany
Peter F.
Reply With Quote
  #5 (permalink)  
Old 02-10-04, 17:06
dctoph dctoph is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
Re: FTP script problem

For anyone else who reads this thread, the proper script should be:

#!/bin/ksh
userString="brsgadmin"
pswdString="brsg6906"
#ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
ifmsfile="COPY_DB_STATUS.DAT"
ftp -in ba0470.optus.com.au <<-END_FTP
user $userString $pswdString
get ${ifmsfile}
quit
END_FTP

echo "file transfer has completed"
date

where "-END_FTP" at the end is changed to "END_FTP" (without the "-" character)

Quote:
Originally posted by adokli
FTP script problem
I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

Please tell me what I am doing wrong here.

#!/bin/ksh
userString="brsgadmin"
pswdString="brsg6906"
#ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
ifmsfile="COPY_DB_STATUS.DAT"
ftp -in ba0470.optus.com.au <<-END_FTP
user $userString $pswdString
get ${ifmsfile}
quit
-END_FTP

echo "file transfer has completed"
date
Reply With Quote
  #6 (permalink)  
Old 02-10-04, 17:32
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
The - betwen << and label END_FTP indicates that datas until END_FTP can be prefixed by a TAB that will be ignored.
The code can be rewritten like this :

Code:
ftp -in ba0470.optus.com.au <<-END_FTP
        user $userString $pswdString
        get ${ifmsfile}
        quit
        END_FTP
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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