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

In reply to Re: Using FTP Without any Modules by serf
in thread Using FTP Without any Modules by perl_devel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.