07-30-2013 12:27 AM
07-30-2013 12:27 AM
Re: ftp.proxy usage for downloadin
g dependenci es of vim depot
I see, your proxy in port 8080 is indeed a HTTP proxy. Even if it allows connections to FTP servers, any programs wishing to use it must understand HTTP, since HTTP is the protocol used to talk with the proxy itself.
Wget is a very suitable tool for your situation: since it can take all its input from the command line, it is very easy to use in scripts.
The depothelper script uses its ftp_file() function to download software. This is the part that does the actual download:
if [ "$proxy_site" = "" ] then ( echo "user anonymous $progname@localhost" echo "binary" echo "get $1 $bfile" echo "quit" ) | ftp -i -n $site >/dev/null 2>&1 else ( echo "user anonymous@$site $progname@localhost" echo "binary" echo "get $1 $bfile" echo "quit" ) | ftp -i -n $proxy_site $proxy_port 2>&1 fi
The variables are all either descriptively named or easily identifiable elsewhere in the script:
- $proxy_site = the hostname or IP address of the proxy, or empty if the -p option is not used
- $proxy_port = the port number of the proxy
- $progname = the name of the depothelper script
- $1 = the full pathname of the file to download (documented at the beginning o the ftp_file() function)
- $bfile = the name of the file to download, without the directory path (a.k.a basename of the file)
- $site = the hostname to connect to (= hpux.connect.org.uk)
The original script uses two different ftp command lines, depending on whether a FTP proxy must be used or not. But since wget can take its proxy information through environment variables, it should be possible to just export the proxy variables if required, and then use the same wget command line to support both cases.
If you replace the part of the depothelper script listed above with this part, the script should work with your proxy:
if [ "$proxy_site" = "" ] then unset ftp_proxy unset http_proxy else export ftp_proxy="http://$proxy_site:$proxy_port" export http_proxy="http://$proxy_site:$proxy_port" fi wget -O $bfile --user=anonymous --password="$progname@localhost" \ ftp://$site$1 >/dev/null 2>&1
NOTE: after the modification, the modified script will not work at all if wget is not installed and usable.
After the modification, the syntax of the depothelper commands is unchanged. The -p option must still be included to the depothelper command line to use a proxy, just as before.