<?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 Pass variable to the ftp script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843328#M936686</link>
    <description>I have the following ftp script and I want the mget or get to copy a different no. of files each time.&lt;BR /&gt;&lt;BR /&gt;#vi ftpscript&lt;BR /&gt;#/!bin/ksh&lt;BR /&gt;ftp $remote_sys &amp;lt;</description>
    <pubDate>Tue, 12 Nov 2002 17:31:45 GMT</pubDate>
    <dc:creator>Stephen Ng</dc:creator>
    <dc:date>2002-11-12T17:31:45Z</dc:date>
    <item>
      <title>Pass variable to the ftp script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843328#M936686</link>
      <description>I have the following ftp script and I want the mget or get to copy a different no. of files each time.&lt;BR /&gt;&lt;BR /&gt;#vi ftpscript&lt;BR /&gt;#/!bin/ksh&lt;BR /&gt;ftp $remote_sys &amp;lt;</description>
      <pubDate>Tue, 12 Nov 2002 17:31:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843328#M936686</guid>
      <dc:creator>Stephen Ng</dc:creator>
      <dc:date>2002-11-12T17:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pass variable to the ftp script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843329#M936687</link>
      <description>I modified your script to look like this (example) :-&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;{ echo user skchan mypassword; echo mget $1; echo quit ; } |ftp -i -n $2&lt;BR /&gt;&lt;BR /&gt;You would then run it like so ..&lt;BR /&gt;# for file in $(cat d)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; ./ftpscript $file &lt;REMOTE-SYSTEM-HOSTNAME&gt;&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;&lt;BR /&gt;The $1 takes in the filename one at a time from the for loop and $2 is the system hostname that you're ftping to. The downside is of course you got to run ftp each time you want to retrieve a file which I suppose is what you wanted because you don't want to use pattern matching to retrieve multiple files in a single session.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/REMOTE-SYSTEM-HOSTNAME&gt;</description>
      <pubDate>Tue, 12 Nov 2002 17:48:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843329#M936687</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-11-12T17:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pass variable to the ftp script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843330#M936688</link>
      <description>why not generate a script on the fly :&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;echo 'ftp $remote_sys&amp;lt;&lt;EOP&gt;&amp;gt; newscript&lt;BR /&gt;echo 'user $remote_user $remote_pass' &amp;gt;&amp;gt;newscript&lt;BR /&gt;cat listfile | while read filename&lt;BR /&gt;do&lt;BR /&gt;echo "get $filename" &amp;gt;&amp;gt;newscript&lt;BR /&gt;done&lt;BR /&gt;echo "bye" &amp;gt;&amp;gt;newscript&lt;BR /&gt;echo "EOP" &amp;gt;&amp;gt;newscript&lt;BR /&gt;&lt;BR /&gt;=================================&lt;BR /&gt;newscript is the script to be executed and listfile is the file with the list of file to be trasnferred. This file is dynamic.&lt;BR /&gt;&lt;BR /&gt;don't forget "chmod +x newscript"&lt;BR /&gt;&lt;BR /&gt;Jean-Luc&lt;BR /&gt;PS : mind the single and double quote&lt;/EOP&gt;</description>
      <pubDate>Tue, 12 Nov 2002 17:53:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843330#M936688</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2002-11-12T17:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pass variable to the ftp script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843331#M936689</link>
      <description>Below is script I use to get data. Using MGET can some time  get to much stuff  Trick I use, Is I first get a list of files on the system.  parse the list and then get the "stuff" I need.  Just a different way to look at the problem.&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;#  ftpget.sh&lt;BR /&gt;#  Purpose:  Retrieves files from a remote location&lt;BR /&gt;#            VIA FTP. This file is usually called from&lt;BR /&gt;#            a  crontab entry.&lt;BR /&gt;#&lt;BR /&gt;# Written by: Rory Hammond &lt;BR /&gt;#&lt;BR /&gt;# I modifed this script by shortening it so that I can share the&lt;BR /&gt;# concepts  The original had a little more error checking and then&lt;BR /&gt;# uploaded data into a database&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# variables need to work&lt;BR /&gt;PATH=$PATH:/usr/bin&lt;BR /&gt;umask 0&lt;BR /&gt;GATEWAYPW="user proxyid proxpasswd"&lt;BR /&gt;REMOTEUPW="user userid passwd"&lt;BR /&gt;REMOTELOC="ftp.location.coml"     #can also be IP Address&lt;BR /&gt;PUTDIR="/usr/spool/receive"&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Getlist lists ftp into site and  list files available&lt;BR /&gt;#  At this site I was only looking for TXT files hence the grep.    &lt;BR /&gt;#&lt;BR /&gt;getlist()&lt;BR /&gt;{&lt;BR /&gt;(  echo ${GATEWAYPW}&lt;BR /&gt;   echo ${REMOTEUPW}&lt;BR /&gt;   echo "ascii"&lt;BR /&gt;   echo "nlist"&lt;BR /&gt;   echo "quit"&lt;BR /&gt;   ) | ftp -n ${REMOTELOC}  |grep TXT&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;#  This gets the files gotten from the getlist. &lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;getfile()&lt;BR /&gt;{&lt;BR /&gt;sleep 5&lt;BR /&gt;(  echo ${GATEWAYPW}     # do not need the first two lines if you don't have a  &lt;BR /&gt;   sleep 5               # a  gateway user ID and password to get out&lt;BR /&gt;   echo ${REMOTEUPW}&lt;BR /&gt;   sleep 5&lt;BR /&gt;   echo "binary"&lt;BR /&gt;   echo "get $1 $1"&lt;BR /&gt;   sleep 5&lt;BR /&gt;   echo "quit"&lt;BR /&gt;   ) | ftp -n ${REMOTELOC}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# grep txt will get all file names ending with txt&lt;BR /&gt;# it  would be faster to put this loop in the getfile&lt;BR /&gt;# script macro but I chose not to.  After words&lt;BR /&gt;# you check the the line count of getlist and compare it&lt;BR /&gt;# with the number of files you did receive.&lt;BR /&gt;# As a  variation you can change the script put files&lt;BR /&gt;# and use the getlist to enuser the the ftp worked.&lt;BR /&gt;#&lt;BR /&gt;for arg in `getlist`&lt;BR /&gt;   do&lt;BR /&gt;   cd ${PUTDIR}&lt;BR /&gt;   getfile ${arg}&lt;BR /&gt;   echo "`date` $0: --- getfile ---"&lt;BR /&gt;   echo "$0:Getting ${arg} and putting it at" ${PUTDIR}/${arg}&lt;BR /&gt;   echo "`date` $0: -----getfile----- transferring ${arg} copy to Mercator"&lt;BR /&gt;   tranfile ${arg}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit</description>
      <pubDate>Wed, 13 Nov 2002 16:49:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variable-to-the-ftp-script/m-p/2843331#M936689</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2002-11-13T16:49:52Z</dc:date>
    </item>
  </channel>
</rss>

