FTP feed back mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP feed back mail
# 1  
Old 11-13-2009
FTP feed back mail

I am having Oracle export script, in that FTP part only given below

ftp -n <<END
open $Server
user $FtpUser $FtpPwd
cd $FtpPath
binary
put $Tablename.flg
put $Filename.gz
bye
END

Now I want to get the feed back (success or fails) message.through mail. can anyone please help on this

Thanks in advance
sbmk
# 2  
Old 11-13-2009
I'd use Per NET::FTP

Something like (skeleton only)

Code:
#!/usr/bin/perl
use Net::FTP;

my $host="Server";
my $directory="pub";

$ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
  push @ERRORS, "Can't ftp to $host: $!\n" if $newerr;
  myerr() if $newerr;
print "Connected\n";

$ftp->login("your user","yourpassword") or $newerr=1;
 push @ERRORS, "Can't ftp to $host: $!\n" if $newerr;
  myerr() if $newerr;
$ftp->cwd("Yourftppath") or $newerr=1; 
  push @ERRORS, "Can't cd  $!\n" if $newerr;
  $ftp->quit if $newerr;
  myerr() if $newerr;
  foreach (@file-list) {
   print "Putting $_\n";
    $ftp->put($_,$_) or $newerr=1;
      push @ERRORS, "Couldn't get $stuff[3] $!\n" if $newerr;
   }

   }

   $ftp->quit;
   myerr();



sub myerr {

  # send this stuff to mailo, code not shown
  print "Error: \n";
  print @ERRORS;
  exit 0;
}


See more examples at my Perl Net::FTP
# 3  
Old 11-13-2009
I haven't tested it, but I'm pretty certain you can just test $? after your code. If it's non-zero it failed.

ftp <<END
...
...
...
END

ERR_CODE=$?

if [ "${ERR_CODE}" -eq 0 ]; then
MSG=SUCCESS
else
MSG=FAILURE
fi

mailx .....
# 4  
Old 11-16-2009
Hi jsmithstl,
$? -not working

I tested with wrong FTP User name, but the code does not going to else part. Any other code/Book ? Please...........

Thanks in advance
sbmk
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Open Source

Shell script file movement to a Mail Box server using ftp commands

Hi All, I have a current Process that runs "windows script " for the file movement that needs to changed to a "DataStage Process (Using shell script )" Source :Text file is getting generated as part of Datastage Jobs processes and resides in a shared drive (Unix server) Target :ftp... (2 Replies)
Discussion started by: developer.dwh9
2 Replies

2. Red Hat

Postfix Gateway with Exchange Mail With MX back-up

Hello, We have been looking for ways of implementing some redundancy on our postfix gateways in our company. We have 4 Postfix Gateways. mail2.domain.ro 10 mail.domain.ro 20 mail1.domain.ro 30 mail3.domain.ro 40 On nslookup we have like this: domain.ro MX preference = 10,... (0 Replies)
Discussion started by: panaitescuionel
0 Replies

3. Solaris

Mail loops back to me error in /var/adm/message after patching

Hi, I am getting the below messsage in /var/adm/message after patching but sendmail is working after restoring the backup file. sendmail: q4G7U1Cj014774: SYSERR(root): 127.0.0.1 config error: mail loops back to me (MX problem?) sendmail: q4G801cw025824: SYSERR(root): 127.0.0.1 config... (3 Replies)
Discussion started by: fayaz
3 Replies

4. UNIX for Dummies Questions & Answers

Mail/ftp/web servers, on VIRTUAL!! dedicated server. Also resource usage. Centos 5.

Hi. First of all, would 4 or 5 websites, 1 ftp server (when downloading by someone or a few persons or one, concretize) and one mail server (not many emails, just to sound official and have a nice, spam-free email for myself). Websites with not that many, but some, later more visitors, quite... (0 Replies)
Discussion started by: newn
0 Replies

5. AIX

Mail bounced back externally - internally ok.

I am unable to send mail externally. It gets refused from any mail server. Here's my current config: oslevel -s 5300-07-05-0831 ******** mail -v foo@yahoo.com < /tmp/oracle.out Warning: .cf file is out of date: sendmail AIX5.3/8.13.4 supports version 10, .cf file is version 9... (3 Replies)
Discussion started by: gravy26
3 Replies

6. Shell Programming and Scripting

replace last form feed with line feed

Hi I have a file with lots of line feeds and form feeds (page break). Need to replace last occurrence of form feed (created by - echo "\f" ) in the file with line feed. Please advise how can i achieve this. TIA Prvn (5 Replies)
Discussion started by: prvnrk
5 Replies

7. Shell Programming and Scripting

ftp username with back slash

Hi, My ftp user name is in the format US\tere I tried using escape characters US\\tere but it is not working fine please advice.. sam (1 Reply)
Discussion started by: sam99
1 Replies

8. Shell Programming and Scripting

FTP'ing files with filenames in mail messege

Hi, I have created the following FTP script, which transfers daily “.txt” files from remote server in to a timestamped folder on local server. Once all files are FTP'ed, it then deletes files from remote server. When files are FTP'ed, I get a mail messege like, “Files are successfully transfered”,... (1 Reply)
Discussion started by: berlin_germany
1 Replies

9. Linux

Linux as FTP & Mail server

How do i setup my linux server to act as a internal ftp server. i have 30 machines who would want to log onto external ftp servers ( for hosting and stuff ). They would have to go through a ftp server on the network server to get outside to the internet? What program on linux would i use How... (6 Replies)
Discussion started by: perleo
6 Replies

10. UNIX for Dummies Questions & Answers

553 config error: mail loops back to me (MX problem)

I recieve 553 5.3.4 mail.xxxx.com config error: mail loops back to me (MX problem?) when I try to send email from client . The message reaches the server and dies there I'm using sendmail 8.12.9 on OpenBSD 3.3. I can check mail on client with no problem Thanks for any help (5 Replies)
Discussion started by: bluehell
5 Replies
Login or Register to Ask a Question