Automating FTP in Linux and Win95
Updated September 12, 2002
Created December 1, 2002


Autogenerated Site Map
Search this Site!:
Search this site powered by FreeFind


Linux

#!/bin/sh

#Backup current ~/.netrc file if it exists

PREVIOUS_NETRC=NO
if [ -e ~/.netrc ]
     then
     mv ~/.netrc ~/.netrc.$$
     PREVIOUS_NETRC=YES
fi


#Set up some variables

FTP_SERVER=emperor.cs.hou.compaq.com
FTP_DIRECTORY=/pub/RedHat62/i386
EMAIL_ADDR=MyEmail@MyISP.com

#Create a new ~/.netrc for this download

cat <<EOF>~/.netrc
machine $FTP_SERVER login anonymous password $EMAIL_ADDR
macdef init
bin
hash
lcd /tmp
cd $FTP_DIRECTORY/images/
get bootnet.img bootnet.img.$$
quit

default login anonymous password $EMAIL_ADDR
EOF


#Begin the Download

cd /tmp
ftp $FTP_SERVER

#Cleanup after Downloading

if [ $PREVIOUS_NETRC = YES ]
     then
     mv ~/.netrc.$$ ~/.netrc
     unset PREVIOUS_NETRC
else
     rm ~/.netrc
     unset PREVIOUS_NETRC
fi






Win95


REM Set up some variables
set FTP_SERVER=emperor.cs.hou.compaq.com
set FTP_DIRECTORY=/pub/RedHat62/i386
set EMAIL_ADDR=MyEmail@MyISP.com

REM Create an ftp configuration file called getbootdisk.txt
echo open %FTP_SERVER%> %TEMP%\getbootdisk.txt
echo anonymous>> %TEMP%\getbootdisk.txt
echo %EMAIL_ADDR%>> %TEMP%\getbootdisk.txt
echo bin>> %TEMP%\getbootdisk.txt
echo hash>> %TEMP%\getbootdisk.txt
echo get %FTP_DIRECTORY%/images/bootnet.img>> %TEMP%\getbootdisk.txt
echo get %FTP_DIRECTORY%/dosutils/rawrite.exe>> %TEMP%\getbootdisk.txt

REM Begin the download
cd %TEMP%
ftp -s:%TEMP%\getbootdisk.txt

REM Clean up after the download
del %TEMP%\getbootdisk.txt


Search this Site!:
Search this site powered by FreeFind

Homepage: http://www.cpqlinux.com
Site Map: http://www.cpqlinux.com/sitemap.html