Hi all, My web hosting company provides a web interface for backing up my site. I'd like to create a script (that is run from a shell) that automates this process. So I have come up with the code below. I created a code base by using a proxy (as detailed in the book Spidering Hacks) to record my actions as a web client and went through the process of backing up my site through my hosting companies web based admin interface. The hosting company provides a link that the user can click on that will create a .tar.gz file backup for the entire site.
The code first logs in and gets a session key. It then goes to the back up interface page and calls the backup function --> backup?func=create+backup However when I run this code from a shell with --> perl backup.pl -- it never completes the backup. Furthermore if I then login to the site with a web browser and check on the status of the backup, it states the back up is still in progress. So the code below actually sets a the backup process into motion but never finishes the task. So there must be some kind of interaction that is happening with the web browser to make it work with the web browser and not with the shell code implementation. Any suggestions on how I can get the backup function to complete it's task? Here is the code: #!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; ### request number 27 ### my $req27 = HTTP::Request->new(GET => ' http://domain.com/vdeck '); $req27->header('Host' => 'domain.com'); $req27->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req27->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req27->header('Accept-Language' => 'en-us,en;q=0.5'); $req27->header('Accept-Encoding' => 'gzip,deflate'); $req27->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req27->header('Keep-Alive' => '300'); $req27->header('Cookie' => 'lang=english'); print $ua->request($req27)->as_string; ### request number 28 ### my $req28 = HTTP::Request->new(GET => ' http://hostxxx.hp.com:8080/panel/index?vDeck_session=lotsasessionkeycharactersheredsf3dsa34adf '); $req28->header('Host' => 'hostxxx.hp.com:8080'); $req28->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req28->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req28->header('Accept-Language' => 'en-us,en;q=0.5'); $req28->header('Accept-Encoding' => 'gzip,deflate'); $req28->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req28->header('Keep-Alive' => '300'); $req28->header('Cookie' => 'vDecksession=lotsasessionkeycharactersheredsf3dsa34adf'); print $ua->request($req28)->as_string; ### request number 42 ### my $req42 = HTTP::Request->new(GET => ' http://domain.com/checkvdeckdns?domain.com '); $req42->header('Host' => 'domain.com'); $req42->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req42->header('Accept' => 'image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req42->header('Accept-Language' => 'en-us,en;q=0.5'); $req42->header('Accept-Encoding' => 'gzip,deflate'); $req42->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req42->header('Keep-Alive' => '300'); $req42->header('Referer' => 'http://hostxxx.hp.com:8080/panel/index?vDeck_session=lotsasessionkeycharactersheredsf3dsa34adf'); $req42->header('Cookie' => 'lang=english'); print $ua->request($req42)->as_string; ### request number 63 ### my $req63 = HTTP::Request->new(GET => ' http://hostxxx.hp.com:8080/panel/host/backup '); $req63->header('Host' => 'hostxxx.hp.com:8080'); $req63->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req63->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req63->header('Accept-Language' => 'en-us,en;q=0.5'); $req63->header('Accept-Encoding' => 'gzip,deflate'); $req63->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req63->header('Keep-Alive' => '300'); $req63->header('Proxy-Connection' => 'keep-alive'); $req63->header('Referer' => 'http://hostxxx.hp.com:8080/panel/index?1'); $req63->header('Cookie' => 'vDecksession=c3eb972ff58c871865afa05e798c8254'); print $ua->request($req63)->as_string; ### request number 64 ### my $req64 = HTTP::Request->new(GET => ' http://hostxxx.hp.com:8080/panel/host/backup?func=create+backup '); $req64->header('Host' => 'hostxxx.hp.com:8080'); $req64->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req64->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req64->header('Accept-Language' => 'en-us,en;q=0.5'); $req64->header('Accept-Encoding' => 'gzip,deflate'); $req64->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req64->header('Keep-Alive' => '300'); $req64->header('Referer' => 'http://hostxxx.hp.com:8080/panel/host/backup'); $req64->header('Cookie' => 'vDecksession=c3eb972ff58c871865afa05e798c8254'); print $ua->request($req64)->as_string; ### request number 65 ### my $req65 = HTTP::Request->new(GET => ' http://hostxxx.hp.com:8080/panel/host/backup?func=create+backup '); $req65->header('Host' => 'hostxxx.hp.com:8080'); $req65->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req65->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req65->header('Accept-Language' => 'en-us,en;q=0.5'); $req65->header('Accept-Encoding' => 'gzip,deflate'); $req65->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req65->header('Keep-Alive' => '300'); $req65->header('Referer' => 'http://hostxxx.hp.com:8080/panel/host/backup?func=create+backup'); $req65->header('Cookie' => 'vDecksession=c3eb972ff58c871865afa05e798c8254'); print $ua->request($req65)->as_string; ### request number 66 ### my $req66 = HTTP::Request->new(GET => ' http://hostxxx.hp.com:8080/panel/host/backup?func=create+backup '); $req66->header('Host' => 'hostxxx.hp.com:8080'); $req66->header('User-Agent' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7'); $req66->header('Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1'); $req66->header('Accept-Language' => 'en-us,en;q=0.5'); $req66->header('Accept-Encoding' => 'gzip,deflate'); $req66->header('Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req66->header('Keep-Alive' => '300'); $req66->header('Referer' => 'http://hostxxx.hp.com:8080/panel/host/backup?func=create+backup'); $req66->header('Cookie' => 'vDecksession=c3eb972ff58c871865afa05e798c8254'); print $ua->request($req66)->as_string;