<?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 FTP script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483350#M704497</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please find below the FTP script which I have written:&lt;BR /&gt;&lt;BR /&gt;inp=ftp.config&lt;BR /&gt;file=abc&lt;BR /&gt;file1=def&lt;BR /&gt;for serv in `cat $inp`&lt;BR /&gt;do&lt;BR /&gt;echo $serv&lt;BR /&gt;echo "Trying to connect to $serv" &amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;ftp -i -n &amp;lt;&amp;lt;-EOF &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;open $serv&lt;BR /&gt;user anonymous&lt;BR /&gt;as&lt;BR /&gt;cd /tmp&lt;BR /&gt;prom&lt;BR /&gt;mget $file&lt;BR /&gt;quit&lt;BR /&gt;EOF&lt;BR /&gt;STAT=$?&lt;BR /&gt;echo $STAT&lt;BR /&gt;if [ ${STAT} = "0" ]; then&lt;BR /&gt;echo "FTP SUccessful to the server $serv" &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;else&lt;BR /&gt;echo "There were some problems in connecting to $serv " &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I am reading the server names from the input file and trying to connect to all the servers in the input file.&lt;BR /&gt;&lt;BR /&gt;The script works good but the problem is that whenever a particular server is not reachable due to some network problem, the script times out. But my requirement is that the script should send a message to the log that it is not able to connect to a server and move on to the next server.&lt;BR /&gt;&lt;BR /&gt;I have tried to use the FTP return status but it seems to be 0 even when the server is not reachable.&lt;BR /&gt;&lt;BR /&gt;Is there a way in which I return an error to the FTP log file in case the file which I am trying to obtain is not availble in the server.&lt;BR /&gt;&lt;BR /&gt;Also, I have to obtain '$file1' in case '$file' is not available. I don't know how to do this.&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anand</description>
    <pubDate>Thu, 10 Feb 2005 18:07:19 GMT</pubDate>
    <dc:creator>Anand_30</dc:creator>
    <dc:date>2005-02-10T18:07:19Z</dc:date>
    <item>
      <title>FTP script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483350#M704497</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please find below the FTP script which I have written:&lt;BR /&gt;&lt;BR /&gt;inp=ftp.config&lt;BR /&gt;file=abc&lt;BR /&gt;file1=def&lt;BR /&gt;for serv in `cat $inp`&lt;BR /&gt;do&lt;BR /&gt;echo $serv&lt;BR /&gt;echo "Trying to connect to $serv" &amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;ftp -i -n &amp;lt;&amp;lt;-EOF &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;open $serv&lt;BR /&gt;user anonymous&lt;BR /&gt;as&lt;BR /&gt;cd /tmp&lt;BR /&gt;prom&lt;BR /&gt;mget $file&lt;BR /&gt;quit&lt;BR /&gt;EOF&lt;BR /&gt;STAT=$?&lt;BR /&gt;echo $STAT&lt;BR /&gt;if [ ${STAT} = "0" ]; then&lt;BR /&gt;echo "FTP SUccessful to the server $serv" &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;else&lt;BR /&gt;echo "There were some problems in connecting to $serv " &amp;gt;&amp;gt; /tmp/ftp_log.${serv}&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I am reading the server names from the input file and trying to connect to all the servers in the input file.&lt;BR /&gt;&lt;BR /&gt;The script works good but the problem is that whenever a particular server is not reachable due to some network problem, the script times out. But my requirement is that the script should send a message to the log that it is not able to connect to a server and move on to the next server.&lt;BR /&gt;&lt;BR /&gt;I have tried to use the FTP return status but it seems to be 0 even when the server is not reachable.&lt;BR /&gt;&lt;BR /&gt;Is there a way in which I return an error to the FTP log file in case the file which I am trying to obtain is not availble in the server.&lt;BR /&gt;&lt;BR /&gt;Also, I have to obtain '$file1' in case '$file' is not available. I don't know how to do this.&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anand</description>
      <pubDate>Thu, 10 Feb 2005 18:07:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483350#M704497</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2005-02-10T18:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: FTP script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483351#M704498</link>
      <description>Let me show you a much easier way using a Perl script which will do all the status and timeout stuff and can check for connectivity.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;inp=ftp.config&lt;BR /&gt;file=abc&lt;BR /&gt;dir=/tmp&lt;BR /&gt;USER=anonymous&lt;BR /&gt;&lt;BR /&gt;cat ${inp} | while read SERV&lt;BR /&gt;  do&lt;BR /&gt;     echo "Testing connection to ${SERV} \c"&lt;BR /&gt;     ftpget.pl -h ${SERV} -l ${USER} -z&lt;BR /&gt;     STAT=${?}&lt;BR /&gt;     if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;       then&lt;BR /&gt;         echo "Ok"&lt;BR /&gt;         echo "Getting file ${file} \c"&lt;BR /&gt;         ftpget.pl -h ${SERV} -l ${USER} -d ${dir} -B -t 3 ${file}&lt;BR /&gt;         STAT=${?}&lt;BR /&gt;         if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;            then&lt;BR /&gt;               echo "Ok"&lt;BR /&gt;            else&lt;BR /&gt;               echo "Failed to get file ${file} from host ${SERV}; status ${STAT}" &amp;gt;&amp;amp;2&lt;BR /&gt;       else&lt;BR /&gt;         echo "Failed to connect to ${SERV}. Status ${STAT}" &amp;gt;&amp;amp;2&lt;BR /&gt;       fi&lt;BR /&gt;  done&lt;BR /&gt;   &lt;BR /&gt;&lt;BR /&gt;Invoke as ftpget.pl -u for full usage. Once you start using Perl for FTP, you will never use the kludgy shell scripts again.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Feb 2005 18:27:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483351#M704498</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-10T18:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: FTP script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483352#M704499</link>
      <description>I would go with Stephenson's perl script, but if you&lt;BR /&gt;must use shell script, you could ping the ftp server&lt;BR /&gt;before doing the ftp.&lt;BR /&gt;&lt;BR /&gt;ping FTPSERVER -n 1 | grep -q "100% packet loss"&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;    echo "FTP_SERVER unreachable"&lt;BR /&gt;else&lt;BR /&gt;   .... your script here&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Ping will timeout much quicker than ftp.&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Feb 2005 18:42:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483352#M704499</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-02-10T18:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: FTP script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483353#M704500</link>
      <description>Hi Stephenson,&lt;BR /&gt;&lt;BR /&gt;I have used your solution. It works great.&lt;BR /&gt;&lt;BR /&gt;But I have a question. Sometimes I am having to fetch file say abc_${value}_*.&lt;BR /&gt;&lt;BR /&gt;I understand from ftpget.pl that I have to use "-L" option when I am trying to fetch files that match some pattern.&lt;BR /&gt;&lt;BR /&gt;I tried using the following command&lt;BR /&gt;&lt;BR /&gt;ftpget.pl -h ${SERV} -l {USER} -p ${PASS} -A -t 3 -L 'abc_${value}_*'&lt;BR /&gt;&lt;BR /&gt;It returns only the name of the file like abc_1234_98918. But it does not fetch the file.&lt;BR /&gt;&lt;BR /&gt;Can you please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anand</description>
      <pubDate>Fri, 11 Feb 2005 20:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483353#M704500</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2005-02-11T20:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: FTP script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483354#M704501</link>
      <description>The -L option is working as intended. It lists files matching a pattern in the -d dir. It does not do a get. After you get the list of files, you then issue another ftpget.pl command.&lt;BR /&gt;&lt;BR /&gt;ftpget.pl -h remotehost -l user -p passwd -d /xxx/yyy file1 file2 file3&lt;BR /&gt;&lt;BR /&gt;This will get file1, file2, and file3 from directory /xxx/yyy on the remotehost.&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Feb 2005 22:33:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ftp-script-help/m-p/3483354#M704501</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-11T22:33:12Z</dc:date>
    </item>
  </channel>
</rss>

