Reconnect and download data from online site


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reconnect and download data from online site
# 1  
Old 05-06-2009
Reconnect and download data from online site

Hi,

I have to connect to online site and download some data from the online site but sometimes the site which i have to connect will be busy
or it will not be working in such a case i have to connect atleast 3 times and try to download the data.

I tried like this:

Code:
use CGI::Carp qw(fatalsToBrowser);

$url="http://www.xyz.com";

$ua = new LWP::UserAgent;

$tries=0;

eval
{
$response=$ua->get($url);
};warn $@ if ($@);
if ($@) {
         die "Server error: $@.  Try again later" ;
         $tries++;
	 if($tries == "3")
	 {

		print "\nstop connecting\n"
	 } 
     }

Actually i am stuck up here if there is any error it is not displaying i.e its not
entering if($@) block . How to reconnect again???

Basically i have to reconnect and download the data when the site is not working.

How to reconnect to the site and download the data???


Any suggestions ???


Regards
Vanitha

Last edited by Franklin52; 05-06-2009 at 05:34 AM.. Reason: code tags
# 2  
Old 05-06-2009
that's because you use die.
# 3  
Old 05-06-2009
Quote:
Originally Posted by ghostdog74
that's because you use die.
Hi,

Thanks for the reply!!

what should i use?

I removed die but still its not working!

How can i reconnect and download data?


Regards
Vanitha
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Download a site

A buddy of mine was telling me last night that you can write a bash script that will download an entire site in gedit?? Is this true??? I think I am going to fall in love with bash :D Any good tutorials?? (15 Replies)
Discussion started by: graphicsman
15 Replies

2. Shell Programming and Scripting

lftp script to connect to external sftp site and download to internal ftp and then send email

Hi there, I'm new to shell scripting and need some help if possible? I need to create a shell script (.sh) to run as a cron job on an ubuntu linux server to connect to an external sftp sites directory using credentials (which I have) and then download to our internal ftp server and then copy... (3 Replies)
Discussion started by: ghath
3 Replies

3. Shell Programming and Scripting

Wget, download file from site's folder.

Ok, this is quite weird. wget -r mysite.com/mylink/ should get all the files recursively from the 'mylink' folder. The problem is that wget saves an index.html file! When I open this index.html with my browser I realize that it shows all the files in the current folder (plus an option to move... (3 Replies)
Discussion started by: hakermania
3 Replies

4. UNIX for Dummies Questions & Answers

Download image every 24hrs + put it in php site

Hi everyone, I am all new to this and I might not know what I am asking about :) I have access to a cPanel with cron tab scheduler. I know nothing re scripting creating php etc.. I own a ftp mainly for own email address, some storage, and a forum (ready-made one :P ) I have some knowledge... (5 Replies)
Discussion started by: zYx
5 Replies

5. Linux

shell script to download files from a site?

Hey everyone, my wife has purchased a bundle package of a bunch of images from a site, and now has to download each one of them manually. There are about 500 downloads, and it's quite a hassle to browse to each page and download them all individually. I would like to write a shell script to... (2 Replies)
Discussion started by: paqman
2 Replies

6. Shell Programming and Scripting

script for download files from ftp site

I'm new to scripting. I'm trying to write a script to download files from ftp site, the following is the script and the message i get after running the script. no files were downloaded :( Thanks advance! script: #!/usr/bin/ksh DAY=`date --date="-1 days" +%y%m%d` ftp -v -n "ftp.address" <<... (5 Replies)
Discussion started by: tiff-matt
5 Replies

7. Programming

How to reconnect to online database?

HI, I am using perl LWP for connecting to online databases. some times i will get connection fail. I want to keep track of that error and again i want to connect. i.e when i get connection fail the program should not stop it should try to connect. I can check connection fail has... (1 Reply)
Discussion started by: vanitham
1 Replies

8. Programming

Online site on Makefile

Hi, I would like to learn about Makefile. Can anybody suggest me any online site from where I can get detail information? Thanks. (2 Replies)
Discussion started by: bkausik
2 Replies
Login or Register to Ask a Question