FTP upload


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP upload
# 1  
Old 06-06-2011
FTP upload

Hi All,

I am new to this forum and i need help from you .

Here i want to get a mail conformation when ever the file was uploaded to FTP server.Here is my FTP script . Can any one plz help me how to get a mail confirmation weather the file was uploaded or not.
Code:
#!bin/sh

HOST='192.168.2.85'
USER='ddd'
PASSWD='dfd'

#FILE='*'

#DT=$(date +%a_%h_%d_%Y)
DT=$(date +%Y-%m-%d)

ftp -n $HOST > .ftpout.txt 2>.ftperr.txt <<END_SCRIPT

quote USER $USER
quote PASS $PASSWD

#lcd /home/oracle/test
lcd /u03/APDEXTS/

mkdir TEST
cd TEST
mkdir $DT
cd $DT

prompt
mput *.cec
quit

END_SCRIPT
exit 0

Thanks & Regards,
Pooran Prasad.

Last edited by pludi; 06-06-2011 at 05:47 AM..
# 2  
Old 06-06-2011
After the END_SCRIPT

Code:
if [ "$?" eq "0" ] 
then
    echo "FTP operation Successful" | mail -s "Success :: FTP Status" abc@xyz.com
else
    echo "FTP operation Failed" | mail -s "Failure :: FTP Status" abc@xyz.com
fi

# 3  
Old 06-06-2011
Hi,

I have added the below code in my script and when the file was uploading we are getting success mail and even when the file was not uploaded also we are getting the same success mail .

Here I changed my ftp server ip and tried to run the script but i am getting success mail only.

Here is my script.
Code:
#!bin/sh

HOST='192.168.2.85'
USER='ss'
PASSWD='ss'

#FILE='*'

#DT=$(date +%a_%h_%d_%Y)
DT=$(date +%Y-%m-%d)

ftp -n $HOST > .ftpout.txt 2>.ftperr.txt <<END_SCRIPT

quote USER $USER
quote PASS $PASSWD

#lcd /home/oracle/test
lcd /u03/APDEXTS/

#mkdir APD_TEST
#cd APD_TEST
#mkdir $DT
#cd $DT

prompt
mput *.cec
quit

END_SCRIPT

if [ "$?" = "0" ]
then
    echo "FTP operation Successful" | mail -s "Success :: FTP Status" user@somewhere.com
else
    echo "FTP operation Failed" | mail -s "Failure :: FTP Status" user@somewhere.com
fi

exit 0



Thanks & Regards,
Poorna Prasad.S

Last edited by pludi; 06-06-2011 at 05:47 AM..
# 4  
Old 06-06-2011
Quote:
Originally Posted by itkamaraj
After the END_SCRIPT

Code:
if [ "$?" eq "0" ] 
then
    echo "FTP operation Successful" | mail -s "Success :: FTP Status" abc@xyz.com
else
    echo "FTP operation Failed" | mail -s "Failure :: FTP Status" abc@xyz.com
fi

I don't think this will work out, ftp command will always end successfully after you enter quit at ftp prompt. How could you check the exit status of ftp command to identify whether the file transimission was successful.

It won't work as far as i have tested. The proper way is to check the ftp logs and check for the error code in the log. You have checck for error codes starting from 300 - 599 for any errors.

Quote:
I have added the below code in my script and when the file was uploading we are getting success mail and even when the file was not uploaded also we are getting the same success mail .
Please try this, add the below line before the if condition and just after the END_SCRIPT,

Code:
grep -e "^5[0-9][0-9]" -e "^4[0-9][0-9]" .ftperr.txt

# 5  
Old 06-06-2011
I see, then probably we need to check the log file as mentioned by the kumaran

thanks for the info
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Upload latest file to ftp

Hi, I want to create a script that parses the content of a file (on each line there is a filename with full path containing the latest fiels created on that day) and uploads every file to a ftp location. Any elegant way to do it ? (4 Replies)
Discussion started by: liviusbr
4 Replies

2. Solaris

Defumask and upload directive in ftp

Hi, I'm aware that this question has been raised earlier and the solution provided has not helped me. So, the issue is that I'm trying to set a defumask to files transferred via ftp to be 002 so that the group may have write permissions to the files uploaded. We have local/system users... (5 Replies)
Discussion started by: maverick_here
5 Replies

3. Shell Programming and Scripting

Find files and upload to FTP Server

HI, I need a script to find new files that created after 6:00 from /home/ugh /demo/conn /UAT/d01 and upload them into ftp server according to system date: Please help me (1 Reply)
Discussion started by: refra
1 Replies

4. Shell Programming and Scripting

FTP Upload

Can any one help in writing FTP upload script using bash .. with specific port -oPort=62022 #/bin/bash FTPU="username" # ftp login name FTPP="password" # ftp password FTPS="localhost.com" # remote ftp server FTPF="/test" # remote ftp server directory for $FTPU & $FTPP port="2345"... (3 Replies)
Discussion started by: ram5019
3 Replies

5. Shell Programming and Scripting

bash script for ftp-upload is not working

Hello everyone, sorry for the title, most of you must getting sick of reading something like this, but I haven't found a solution, although I found many threads according to it. I'm working on a bash script that connects to a network printer with ftp where I want to upload a pdf created... (3 Replies)
Discussion started by: le_mae
3 Replies

6. Shell Programming and Scripting

Upload files from desktop to unix through FTP

Hi , I want to upload some files from my desktop to unix server through FTP . The list of files are in a text file .Please suggest how to do it through scrip . Thanks in advance .. Anupam (8 Replies)
Discussion started by: anupamhalder
8 Replies

7. Shell Programming and Scripting

Ftp from server1 and upload to server3 from server2

Hi , i have three server server1 -> Unix OS ,ftp enable IP ->10.8.219.190 server 2 -> Unix OS ,ftp enable NIC 1 IP ->10.8.219.191 ,NIC2 ->192.168.0.5 server3 -> windows OS ,ftp enable NIC1 ->192.168.0.6. hence server 1 and server 3 can not communicate ,but server 2 can... (1 Reply)
Discussion started by: suchintkotia
1 Replies

8. HP-UX

not able to upload the pjl commands thru ftp

Hi , By status requests to the printer using the PJL commands like status_read_back there is no answer. The printer itself is functioning well and is printing all requests. Ping, lpstat -t, nslookup is functioning well. The printer model is HP LJ 4200. The printer has been configured as network... (1 Reply)
Discussion started by: amit kul
1 Replies

9. Linux

upload FTP

I have a ftp server up , however when I upload a file from my desktop to the server I get this message: ftp> get uploadtest.txt Local: uploadtest.txt Remote: uploadtest.txt 227 passive Mode ( 192,168,0,1,190,75) 550 Failed to open file ftp> (3 Replies)
Discussion started by: keliy1
3 Replies

10. UNIX for Advanced & Expert Users

Ftp Upload Folder

Hi! I'd like to upload a complete folder with subfolders with put. At the moment I always get the err-msg: aboutme: not a plain file Could anyone help me?? Thanx (3 Replies)
Discussion started by: roberthawke
3 Replies
Login or Register to Ask a Question