<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FTP and error codes in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998234#M296853</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Use with the verbose option.&lt;BR /&gt;&lt;BR /&gt;Try the below one:&lt;BR /&gt;&lt;BR /&gt;# cat /dir/input&lt;BR /&gt;/usr/bin/ftp -v -n &amp;gt; /var/tmp/ftpscript.log 2&amp;gt; /var/tmp/ftpscript.err &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;open servername.domain&lt;BR /&gt;user name password&lt;BR /&gt;prompt&lt;BR /&gt;cd /ddir&lt;BR /&gt;bin&lt;BR /&gt;mput file*&lt;BR /&gt;ls /tmp &lt;BR /&gt;quit&lt;BR /&gt;EOF &lt;BR /&gt;&lt;BR /&gt;#sh /dir/input (run the script input)&lt;BR /&gt;&lt;BR /&gt;after that re-direct /var/tmp/ftpscript.err by mail (or both the output files -log and err) to you.&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
    <pubDate>Sun, 13 May 2007 05:13:25 GMT</pubDate>
    <dc:creator>Rasheed Tamton</dc:creator>
    <dc:date>2007-05-13T05:13:25Z</dc:date>
    <item>
      <title>FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998227#M296846</link>
      <description>We have a script that automatically puts files to a remote system (see below).  The problem is that we have no way of telling if there was a problem.  Like if the server is down or the transfer doesn't work....we still get an error code ($?) of 0 which is the same code if it works properly.  Is there a way for ftp to let you know (via email) if there is a problem?&lt;BR /&gt;&lt;BR /&gt;ftp -i -n &lt;BR /&gt;# cat /dir/input&lt;BR /&gt;open servername.domain&lt;BR /&gt;user name password&lt;BR /&gt;bin&lt;BR /&gt;ls   (just using ls for testing purposes)&lt;BR /&gt;close&lt;BR /&gt;quit&lt;BR /&gt;~&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 May 2007 08:55:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998227#M296846</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2007-05-11T08:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998228#M296847</link>
      <description>popular question....&lt;BR /&gt;basically, you need to "log" the output of ftp to a file and then grep for different status codes, like 250.  man "ftpd" for status code lists.  btw: don't check for the "verbage" as it's not standard across implementations</description>
      <pubDate>Fri, 11 May 2007 09:00:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998228#M296847</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-05-11T09:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998229#M296848</link>
      <description>I use a script like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  SEND_STATUS=`echo "user $FTP_USER $FTP_PASSWORD&lt;BR /&gt;    bin&lt;BR /&gt;    cd $REMOTE_USER&lt;BR /&gt;    lcd $LOCALDIR&lt;BR /&gt;    mput $LOCALFILE&lt;BR /&gt;    bye" |  ftp -i -v -n $FTP_HOST | grep -E "^226.*OK.$" |wc -l`&lt;BR /&gt;    if [ $SEND_STATUS -eq 1 ]&lt;BR /&gt;    then&lt;BR /&gt;      echo "File transferred correctly" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;      exit 0&lt;BR /&gt;    else&lt;BR /&gt;        echo "ERROR in ftp\n"  &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo "`date`: Error sending $LOCALFILE to user $REMOTE_USER" | mailx -s "ERROR FTP" $MAILTO&lt;BR /&gt;        exit 1&lt;BR /&gt;    fi&lt;BR /&gt;</description>
      <pubDate>Fri, 11 May 2007 09:06:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998229#M296848</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2007-05-11T09:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998230#M296849</link>
      <description>Hi,&lt;BR /&gt;if you wanted to be paranoid you could do the following steps:&lt;BR /&gt;&lt;BR /&gt;1. checksum the file&lt;BR /&gt;2. push transfer the file&lt;BR /&gt;3. pull transfer the file back&lt;BR /&gt;4. re-calc the checksum&lt;BR /&gt;&lt;BR /&gt;This would highlight any transmission problems, but at the cost of bandwidth and time !</description>
      <pubDate>Fri, 11 May 2007 09:17:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998230#M296849</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-05-11T09:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998231#M296850</link>
      <description>Capturing FTP error codes and interpreting them (2 usually means good) is a royal pain. Use Perl's Net::FTP module and you get error checking for free.&lt;BR /&gt;&lt;BR /&gt;For example, to do your example:&lt;BR /&gt;ftpget.pl -h servername.domain -u user -p password -B -d /etc -L 'w*' &lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "ftpget failed; status ${STAT}." &amp;gt;&amp;amp;2&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;Would log you in to a server (and can optionally read .netrc for a password), set binary mode, cd to /etc, and list all files that conform to 'w*'. Error-checking is done at every step and all you have to do is examine the exit status of the process. If it's zero, all was well. You don't even have to know any Perl. Invoke as ftpget.pl -u for full usage.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 May 2007 09:29:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998231#M296850</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-11T09:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998232#M296851</link>
      <description>and for putting files there is a similar ftpput.pl.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 May 2007 09:30:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998232#M296851</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-11T09:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998233#M296852</link>
      <description>Since ftp can execute a few commands or thousands of commands, it is impossible to return a code that summarizes what happened. If you look at all the possible commands (even though your objective is to see if a file was transferred OK), you'll see that there are several steps that can fail or be successful. For instance, you might want to remove a remote file but that ftp command would fail if the file was already removed. Is that a failure or a success?&lt;BR /&gt; &lt;BR /&gt;Just like ping, there is no meaningful return code about the actual objective because there are so many possibilities and only one number as a return code. &lt;BR /&gt; &lt;BR /&gt;Use the Perl modules.</description>
      <pubDate>Sat, 12 May 2007 17:58:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998233#M296852</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-05-12T17:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: FTP and error codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998234#M296853</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Use with the verbose option.&lt;BR /&gt;&lt;BR /&gt;Try the below one:&lt;BR /&gt;&lt;BR /&gt;# cat /dir/input&lt;BR /&gt;/usr/bin/ftp -v -n &amp;gt; /var/tmp/ftpscript.log 2&amp;gt; /var/tmp/ftpscript.err &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;open servername.domain&lt;BR /&gt;user name password&lt;BR /&gt;prompt&lt;BR /&gt;cd /ddir&lt;BR /&gt;bin&lt;BR /&gt;mput file*&lt;BR /&gt;ls /tmp &lt;BR /&gt;quit&lt;BR /&gt;EOF &lt;BR /&gt;&lt;BR /&gt;#sh /dir/input (run the script input)&lt;BR /&gt;&lt;BR /&gt;after that re-direct /var/tmp/ftpscript.err by mail (or both the output files -log and err) to you.&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Sun, 13 May 2007 05:13:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-and-error-codes/m-p/3998234#M296853</guid>
      <dc:creator>Rasheed Tamton</dc:creator>
      <dc:date>2007-05-13T05:13:25Z</dc:date>
    </item>
  </channel>
</rss>

