xboxscene.org forums

Author Topic: Anyone Interested In An Automatic Ftp Program?  (Read 97 times)

ReKlaTs

  • Archived User
  • Newbie
  • *
  • Posts: 37
Anyone Interested In An Automatic Ftp Program?
« on: September 09, 2003, 06:46:00 AM »

Totally worth posting.. I'd use it!
It would also eliminate some of the newbie questions about how to connect to the xbox ftp, what ftp client to use, etc.,
Logged

Hong Kong Phooey

  • Archived User
  • Jr. Member
  • *
  • Posts: 78
Anyone Interested In An Automatic Ftp Program?
« Reply #1 on: September 14, 2003, 04:32:00 PM »

Dude, that sounds sweet!!
Logged

moistness

  • Archived User
  • Hero Member
  • *
  • Posts: 1093
Anyone Interested In An Automatic Ftp Program?
« Reply #2 on: September 15, 2003, 07:45:00 AM »

smile.gif
Logged

bruce1271

  • Archived User
  • Newbie
  • *
  • Posts: 16
Anyone Interested In An Automatic Ftp Program?
« Reply #3 on: September 17, 2003, 07:43:00 PM »

Ok.. Below is the program and here is a few instructions to get you started:

1) You will need to have perl installed on your windows computer.(See Item 3)
2) Cut and paste the below code into notepad and save it as xboxftp.pl
3) Read the Disclaimer and instructions inside the actual script before starting.

Eventually(soon) this will be part of an MSDos batch file together with isomaker and nero burning rom to burn a DVD,  but for now it is just an FTP program.


Let me know if you have any problems and any feedback..good or bad.
----------------------------------------------------------------------------------------------------


#!/usr/local/bin/perl

#####################################################
####################### Disclaimer #######################
########################################################

#Written Aug 20003 by Bruce H.  Rev 1.0
#I am not responsible for any damage this script does to your computer.
#I have personally tested and used this script many times with no problems,
# but every environment is different.
#Please use it at your own Risk!

############################################
##########Usage & Examples ######################
############################################

# This is an automatic Perl ftp program to run on win32 machines.
# It will ftp into the xbox and then make an exact backup of the D Drive of the XBOX.

# To use this script you need to execute it at the cmd prompt and pass the name of a directory you want the files to go in. It will create the directory automatically.

#First Off you need to have perl installed on your windows machine
#You can download Perl for windows from:
#http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
#Download 5.8.0 Windows MSI - If you have windows.
#Make sure you click on "Put perl in your path" and "Create perl file extension"

#To run the script:

# For Example:
#On a windows XP computer go to "Start->Run and type cmd".
#This will open a cmd.exe window to which you can run this script.
#Then Type "C:xboxftp.pl Rayman3"
#The above line would put the contents of the XBOX dvd-rom(D Drive) in a folder named Rayman3 Located under Drive Letter C on your Windows PC.

# Or Type "C:xboxftp.pl D:Madden2004"
# This creates the folder under your D hard Drive(If you have one on your pc)

##################################################
########### Setup ##################################
#################################################

#You need to set-up the below 3 parameters;Please use " around all fields entered.

#1)Name of the XBOX ip address or hostname.
$xboxip       ="192.168.0.2";

#2)Your xbox FTP username.
$xboxusername ="xbox";

#3)Your xbox FTP Password
$xboxpasswd   ="xbox";


####################################################
####### Anything below here you should not need to adjust  ###########
####################################################

$localdir = "$ARGV[0]";

mkdir ("$localdir");
chdir ("$localdir");

use Net::FTP;

$ftp = Net::FTP->new("$xboxip",Debug => 0,Type => "I");
$ftp->login("$xboxusername","$xboxpasswd")||die "Cant login to servern";
print "Connected to XBOX FTP servern";

$ftp->cwd("/D");
#$ftp->cwd("XB/FTPTEST");

$transfer_total=0;
$xboxtotal=0;
$dostotal=0;
$filecount=
#$filecountdos=0;


#Grab the number of columns in the File
my @files2=$ftp->dir;
foreach my $file2 (@files2){
   @splitfile2=split(" ",$file2);}
$filenameindex=scalar@splitfile2-1;

#Call this procedure to traverse the directory
print "Copying Filesn";
&get_files;
$ftp->quit;

#Calculate some statistics of the transfer Convert to bits and Mb.
$rate = 8*(($xboxtotal/1000000)/$transfer_total);


if ($transfer_total > 60){
   $transfer_total = $transfer_total/60;
   $minsec="minutes";
}
else {
   $transfer_total = $transfer_total;
   $minsec="seconds"
   }


printf "n ** Finished Transferring $filecount Files from $xboxip drive /D **nn$xboxtotal bytes transferred in %.2f $minsec(%.2f Mbs)nn",$transfer_total, $rate;

$xboxtotalmb=$xboxtotal/1000000;
$dostotalmb=$dostotal/1000000;
printf "Size of Data on XBOX Disc  = %.2f Mbn",$xboxtotalmb;
printf "Size of Data on Windows pc = %.2f Mbn",$dostotalmb;
print "Note..It is normal for the Dos Size to be up to a few Mb smallern";
######################################################
#########Sub routine to retrieve files and directories

sub get_files{

 my @files=$ftp->dir;
 
 foreach my $file (@files){
   
   @splitfile=split(" ",$file);
   
   next if $file =~ m/../;
   next if $file =~ m/ ./;
   next if $file =~ m/total/;
   
   
   #If true then the file seen is a directory
   if ($splitfile[0] =~ m/^d/){
     
     print "Making Local Directory for Folder "$splitfile[$filenameindex]"n";
     mkdir ("$splitfile[$filenameindex]");
     chdir ("$splitfile[$filenameindex]");
     $ftp->cwd("$splitfile[$filenameindex]");
     &get_files;
     chdir ("..");
     $ftp->cwd("..");
   }
   
   #Otherwise the object is just a file and ftp it over.
   else {
     $current_dir = $ftp->pwd;
     $local_dir2 = `cd`;
     $xboxtotal = $splitfile[4]+$xboxtotal;

     $start=time;

    # print "FTP'ing file $splitfile[$filenameindex] from Folder $current_dir to Directory $local_dir2 n";
     $ftp->get($splitfile[$filenameindex]);

     $end=time;
     
     $dossize = `dir $splitfile[$filenameindex]`;
     $dossize =~ s/,//gis;    
     $dossize =~ s/.*?(d+) bytes.*/$1/gis;    
     $dostotal = $dostotal+$dossize;
     
     $transfer=$end-$start;
     $transfer_total = $transfer_total + $transfer;
     
     $filecount++;
   }
 }
}
 


## End of FTP Script ##
Logged