Visit Our UNIX and Linux User Community


FTP script error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP script error
# 15  
Old 07-22-2009
Perhaps you could change the

Code:
ls -1 ...

to something like

Code:
find $mFile* -prune ...

# 16  
Old 07-22-2009
didn't work:

when use find $mFile* -prune ... , the LOGFILE is:
/name1/name2/name3

when use find $mFile* ... , the LOGFILE is:
/name1/name2/name3
/name1/name2/name3/file1.txt
/name1/name2/name3/file2.txt
/name1/name2/name3/file3.txt

Last edited by Lenora2009; 07-22-2009 at 05:55 PM..
# 17  
Old 07-22-2009
Quote:
Originally Posted by Lenora2009
didn't work:

-bash: lsit: command not found
We're kind of running low on guessing gas.
Could you possibly elaborate what you're trying and what exactly didn't work?
# 18  
Old 07-22-2009
Here is the FTP error, after changing the FTP script:

Code:
ftp.log:
Connected to host.com.
220 host.local X2 WS_FTP Server 7.0(34062500)
504 unknown security mechanism
504 unknown security mechanism
331 Enter password
230 User logged in
250 Command CWD succeed
250 Command CWD succeed
200 Transfer mode set to BINARY
mput /name1/name2/name3/file10.txt? 227 Entering Passive Mode (10,25
550 Command STOR failed
221 bye

and here is the script:
Code:
#!/bin/bash
DATE=`date +%Y%m%d`
TIME=`date +%H%M%S` 
LOGFILE="process$(date '+%y%m%d')"
mFile="/name1/name2/name3/*.txt"

# Count files
find $mFile  >> $LOGFILE.log
file_ctr=`egrep -cv '#|^$' /name1/name2/$LOGFILE.log` 
echo "$file_ctr"

# User and host info
HOST=host.com'
FTPUSER='user'
PASSWD='password'

# Upload to ftp  -  ftp.log  - all ftp messages 
while read line
do  
ftp -v -n $HOST > /name1/name2/name4/ftp.log <<EOF 
user $FTPUSER
pass $PASSWD 
cd name11
cd name12
bin 
prompt 
mput $line 
bye
EOF 
done </name1/name2/$LOGFILE.log

ftp_ctr=`cat /name1/name2/name4/ftp.log | grep 226 | wc -l` 
if [ "$ftp_ctr" = "$file_ctr" ]; then
echo "No Error"
echo "List of transferred files:" >> ./transfer.txt
else
echo "Error has occured"
echo "List of transferred files:" >> ./error.txt
fi


Last edited by Lenora2009; 07-22-2009 at 08:10 PM..
# 19  
Old 07-22-2009
Quote:
Originally Posted by vgersh99
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
I've never seen this three times in one post!
# 20  
Old 07-22-2009
Looks to me that the prompt command is not working. It appears to be prompting you to see if that is the file to transfer. Hence the ? in
Code:
200 Transfer mode set to BINARY
mput /name1/name2/name3/file10.txt? 227 Entering Passive Mode (10,25
550 Command STOR failed

It is asking you to respond to the question. After the BINARY line you should get something to the effect

Code:
Interactive mode Off

# 21  
Old 07-23-2009
Some subtle changes I would suggest.
Remove "prompt".
Change "mput" to "put". We are only transferring one file in each invocation of ftp.
Because each line in /name1/name2/${LOGFILE}.log is a full pathname we need to extract the filename without the pathname to use for the destination filename (which is going to a different directory name).
Issue a "lcd" such that the ftp starts in the same directory as the source file. You already have "cd" to the destination directory. We can then issue "put filename" without mentioning directory names on the "put" line.

Code:
# Upload to ftp  -  ftp.log  - all ftp messages 
while read line
do
#
FILENAME="`basename ${line}`"      # Name of file without directory
DIRS="`dirname ${line}`"           # Name of source directory
#  
ftp -v -n $HOST > /name1/name2/name4/ftp.log <<EOF 
user ${FTPUSER}
pass ${PASSWD}
lcd ${DIRS}
cd name11
cd name12
bin 
put ${FILENAME} 
bye
EOF 
done </name1/name2/${LOGFILE}.log


Previous Thread | Next Thread
Test Your Knowledge in Computers #391
Difficulty: Medium
Darwin, the open source subset of macOS, has behavior that can be set to comply with UNIX 03.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script FTP maintain error handling

Hi, I have ftp script like below How to insert an error handling, If the transfer failed then send mail to me. Actually, I just need the script to send an email if the FTP failed. How to put the email script within FTP script? Thank You Edy (5 Replies)
Discussion started by: edydsuranta
5 Replies

2. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

3. Shell Programming and Scripting

ftp script error

Hi , I was writing a bash script of ftp to transfer the files , rite now I am considering my local server as ftp server and through keygen -ssh I ahve generated the public & private keys , the private key I have kept in the folder named scripts where my all scripts resides and the public key... (6 Replies)
Discussion started by: rahul125
6 Replies

4. AIX

FTP Script error - AIX

Hi, I'm trying to create a ftp script so I can make an ftp connection and start upload and download files from/to remote servers. In this case I want to start a connection (crontab) and transfer files from localserver1 to remoteserver; remoteserver to localserver1; finally from localserver1... (3 Replies)
Discussion started by: marques_rmc
3 Replies

5. Shell Programming and Scripting

end of file error bash ftp script

Hello kind programmers :) I am a newbie and running into an error "line 28: syntax error: unexpected end of file" on the script shown below. Any help would be greatly appreciated. Thanks! #! /bin/bash if ($#argv <3) then echo 'Usage get_modis_snow ' echo 'ftp script for MYD10A2... (2 Replies)
Discussion started by: cmshreve
2 Replies

6. Shell Programming and Scripting

FTP script error in BASH

Hi All, I have a script which is supposed to connect to Windows machine and FTP a file into LINUX. Script is like below #!/usr/bin/sh ParamterFle=${1} //grepping all parameters BossFtpLog=${2} // assigning log file ftp -i -n host_name << EOF user1 password1 cd /drive1/drive2 get... (6 Replies)
Discussion started by: Raamc
6 Replies

7. Shell Programming and Scripting

Does not exist or unreadable error in windows ftp script

I have a file like this 07200900.SUP,in a windows directory I need to FTP this file to UNIX , the directory in unix is N:\orgs\Financial Aid\MIIS\0910\FTP I am getting this error miis_ftp.ELM_SUP.shl: =cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" : not found IN THE LOG FILE Activities for Mon... (3 Replies)
Discussion started by: rechever
3 Replies

8. Shell Programming and Scripting

FTP script error

Hi all, I am trying to run a FTP script which would go to diff servers in the environment and get the request logs and I am getting the following error, Please let me know. server1.ou.st.com (to) usage: open host-name Not connected. Local directory now /home/pk960/logs Not connected.... (0 Replies)
Discussion started by: crosairs
0 Replies

9. Shell Programming and Scripting

FTP shell script error caturing

Hello All, Can anyone let me know how to capure errors in shell scripting? n even the error considerations? Like -- - File not found what other errors can occure in that n how those could be captured? Im_new (6 Replies)
Discussion started by: im_new
6 Replies

10. UNIX for Dummies Questions & Answers

Error in execting ftp script

Please find the below script: #!/bin/ksh host='gskprod.xyz.com' USER='gsk' PASSWORD='ahdpw1' remote_dir='gsk_ds' ftp -n "${host}" user $USER $PASSWORD binary cd $remote_dir mget *.txt mdelete *.txt bye It does not recognizes userid and password. It executes... (4 Replies)
Discussion started by: jhmr7
4 Replies

Featured Tech Videos