Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Using FTP Without any Modules

by serf (Chaplain)
on Oct 26, 2006 at 08:23 UTC ( #580707=note: print w/ replies, xml ) Need Help??


in reply to Using FTP Without any Modules

Hi perl_devel,

are you Figo Sub - the person that Madhulika wrote this for? Are you Madhulika and you found it at your work?

If you are posting other people's code then you should say it is not yours and where you got it from.

I decided to have a Google for this because I figured someone who would have written that shell could have figured out how to do exactly the same thing in Perl.

Original post (dated 12/10/2003)

#!/bin/ksh Email1="myname@compname.com" #Path of Log file logdir="/log/ftp" # Path of ftp executable ftp="/usr/bin/ftp" # Give port or mention server name IP="111.111.111.111" #User ID to login into remote server user="ftp" #Password to login in remote server pass="ftp" #Mention the path where the file to FTP is lying in the current server ifile="/mainfold/level2fold/filetoftp" #Mention the path where the FILE need to FTPied in the remote server ofile="xyz/filename" #Mention type of data transfer "asc" or "bin" type="asc" # this will take the name of your file myname=`basename $0` #selects the mode verbose="verbose" #date of FTP - Current date dd=`date +%d` # Creating a log file with datestamp log="$logdir/$myname.$dd.log" host=`hostname` rc=0 boj=`date` #ftp block starting - all will be written to log file exec 1>$log 2>&1 echo "---------------------------------------------------" echo " Begin FTP Parameters " echo "---------------------------------------------------" echo "Email Sent To $Email1 " echo "Destination Machine: $IP" echo "User ID: $user" echo "Password: ##############" echo "Destination File: $ofile" echo "---------------------------------------------------" echo " End FTP Parameters " echo "---------------------------------------------------" echo " Begin FTP Session " echo "---------------------------------------------------" echo "open $IP quote USER $user quote PASS $pass $verbose $type put $ifile $ofile close quit" |$ftp -n echo "---------------------------------------------------" echo " End FTP Session " echo "---------------------------------------------------" # FTP block ends #Check the log file for FTP status foo=`grep -i "cannot" $log` if [ "$?" -eq "0" ] ; then rc=1 status="Destination file does not exist\n" fi foo=`grep -i "does not" $log` if [ "$?" -eq "0" ] ; then rc=1 status="${status}Source file does not exist\n" fi foo=`grep -i "killed" $log` if [ "$?" -eq "0" ] ; then rc=1 status="${status}File transfer process has abended\n" fi foo=`grep -i "space" $log` if [ "$?" -eq "0" ] ; then rc=1 status="${status}Ran out of disk space before completion of copy\n" fi if [ "$rc" -eq "0" ] ; then status="Successful" fi # find out the time to ftp. eoj=`date` echo "\nJob start time: $boj" echo "Job end time: $eoj" echo "\nResult code: $rc ($status)" #Mail the status to the email address specified. mailx -s "FTP results from $myname" $Email1 <$log exit 0


Comment on Re: Using FTP Without any Modules
Download Code
Re^2: Using FTP Without any Modules
by ikegami (Pope) on Oct 26, 2006 at 08:56 UTC
    He never said the code was his own, only that he was using it and that he needed help with it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://580707]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2014-10-23 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (128 votes), past polls