NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Why this ftp script can not work properly?



On Fri, May 30, 2008 at 03:25:17AM +0000, Sandglitter wrote:
> Hi, It's me again~
> I come to a problem that confuses me much:
> 
> I have written a ftp shell script to make my work easier, as follow:
> 
> ---------------------------------------------------------
> 
> echo "-----FTP upload transmmision------" 
> echo -n "\n  Please tell me ftp host address:"
> read host 
> echo -n "\n  Please input user name:"
> read username 
> echo -n "  Passwd required:" 
> stty -echo                         
> read userpwd 
> stty echo 
>  
> echo "\n  If you are sure, HIT enter or press Ctl+C"  
> read goenter  
> 
> for file in `ls`             
> do  
>  echo "File $file transmmision in progress......"  
>  sh ftp_auto.sh $host 21 $username $userpwd $file $file      
>  echo "OK" 
> done  
> echo "\nMission complete!!\n"  
> 
> ---------------------------------------------------------------
> and my ftp_auto.sh is as follow:
> 
> ---------------------------------------------------------------
> 
> #!/bin/sh
> 
> 
> ftp -niv $1 $2<<FTPIT 
> quote USER $3
> quote PASS $4
> 
> put $5 $6
> bye
> FTPIT
> 
> ---------------------------------------------------------------
> 
> The strange thing is: the file with big size can not be uploaded completely!
> but shell script output says that every file transfer is 100%!
> I am sure that the file ftp server got is a little bit less than the original 
> one, and if I use ftp command directly to upload the file, every thing is OK!
> 
> Is anyone familiar with this situation?

How about using `ftp -u' instead of the here-document?

     -u URL file [...]
                Upload files on the command line to URL where URL is one
                of the ftp URL types as supported by auto-fetch (with an
                optional target filename for single file uploads), and
                file is one or more local files to be uploaded.


Home | Main Index | Thread Index | Old Index