FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old January 14th, 2004, 10:58 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question opening a file from FTP site

Hi. I'm new here ... seems to be a good forum

I was wondering if someone could help me with the following. I have a perl script that FTP's to a remote site and then uses the get command to retrieve a particular file.

I then want to open the file I have just downloaded. A fragment of the code is shown below:

--------------------------------------------------------------------


open(FTP, "|$ftp -n $ftphost1 > $ftptmp1");
print FTP "user anonymous ";
print FTP "password *my email address here*\n";
print FTP "cd $ftpdir1\n";
print FTP "bin\n";
print FTP "get $pdbfile\n";
print FTP "bye";

close(FTP);

open(DSSPFILE, "$pdbfile") || die "ERROR: Cant open $pdbfile $!\n";

@dsspinfo = <DSSPFILE>;

print "@dsspinfo";

----------------------------------------------------------------------

The problem is the perl script is telling me that the file I have just downloaded is not there, but it clearly is when I take a look on my hard drive (and at the location stated by the open command too).

If I rerun the perl script with the said file already downloaded onto the hard drive, the rst of the program works fine. So, I was wondering if the file is simply not being downloaded quickly enough so the open command is called before the file is actually there? Would that be a fair assumption? And, if so, is there some way of forcing the script to wait for a certain length of time before attempting to open the file?

Oh ... and in case its relevant. I'm on Windows XP, but using the program Exceed to assess a (rather old) SGI (Indigo 2) machine.

Any suggestions would be much appreciated.

Thanks

Mel

Last edited by ffenics : January 14th, 2004 at 11:03 AM.

Reply With Quote
  #2  
Old January 14th, 2004, 11:22 AM
Daytona955i Daytona955i is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Daytona955i User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
You can use sleep(n) where n is number of seconds to wait.

Reply With Quote
  #3  
Old January 14th, 2004, 11:44 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Daytona955i

I tried sleep ... but it didnt seem to work even when I asked the program to pause for 60 seconds ....

Doesnt make any sense. The file in question has most definately been downloaded and it sitting there on my hard drive when I take a look.

Any other suggestions would be much appreciated.

Thanks

Mel

Reply With Quote
  #4  
Old January 14th, 2004, 12:42 PM
quelrat's Avatar
quelrat quelrat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: New York City
Posts: 32 quelrat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Quote:
Originally posted by Daytona955i
You can use sleep(n) where n is number of seconds to wait.

Looks like a hack to me.

According to the perlfunc manual page, close() of a pipe waits for the process to complete. So the file should be present and complete by time your close() returns.

I tried a variant of your code (trying to download both a small file and a large file) and the file is ready to read as soon as the close returns--it worked, in other words.

I tested on Win2K and Linux.

Are you running the code under Irix or WinXP?

Michael

Reply With Quote
  #5  
Old January 15th, 2004, 05:23 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi again

I'm using the code under Irix.

I'm at a loss really. Someone mentioned curl to me ... would that be of help?

Thanks

Mel

Reply With Quote
  #6  
Old January 15th, 2004, 05:37 AM
Axweildr's Avatar
Axweildr Axweildr is offline
CPAN medic ...
Click here for more information.
 
Join Date: Mar 2003
Location: Location: Location:
Posts: 11,283 Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)  Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 23 h 7 m 11 sec
Reputation Power: 2750
Send a message via Google Talk to Axweildr
Orkut
Mel,

Where are you downloading the file to? The same directory as the script?

--Ax

Reply With Quote
  #7  
Old January 15th, 2004, 05:41 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Axweildr

Yes, I am downloading the file to the same directory as the script. Why? Might that cause a problem?

Mel

Reply With Quote
  #8  
Old January 15th, 2004, 05:47 AM
Axweildr's Avatar
Axweildr Axweildr is offline
CPAN medic ...
Click here for more information.
 
Join Date: Mar 2003
Location: Location: Location:
Posts: 11,283 Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)  Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1Folding Points: 122403 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 23 h 7 m 11 sec
Reputation Power: 2750
Send a message via Google Talk to Axweildr
Orkut
Not if its in the same directory, it would cause an issue if it wasn't
Code:
open(DSSPFILE, "<$pdbfile") || die "ERROR: Cant open $pdbfile $!\n";

This shouldn't make much of a difference, but its worth a try

Can you give us the actual name of the file as being returned, and how its stored on disk under irix. It could be a case issue depending on the OS's involved.

HTH
--Ax

Reply With Quote
  #9  
Old January 15th, 2004, 07:08 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,509 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 17 h 57 m 58 sec
Reputation Power: 1322
Generally, I'd use the Net::FTP module for this. See if something like this will work.
Code:
use Net::FTP;

    $ftp = Net::FTP->new($ftphost1, Debug => 0)
      or die "Cannot connect to some.host.name: $@";

    $ftp->login("anonymous",'-anonymous@')
      or die "Cannot login ", $ftp->message;

    $ftp->cwd("/$ftpdir1")
      or die "Cannot change working directory ", $ftp->message;

    $ftp->get($pdbfile)
      or die "get failed ", $ftp->message;

    $ftp->quit;

Reply With Quote
  #10  
Old January 15th, 2004, 09:09 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, and thanks to both Axweildr and ishnid

ishid, unfortunately I dont have the Net::FTP module installed and I dont have permission to do so (seeing as this is a work machine). Thanks for the thought though. Do you know of any thing else that might work that doesnt require installing anything?

Axweildr .. the file is simply a text file. No big deal. Or at least you wouldn think so. I've tried downloading it as binary and ANSI but to no avial.

I'm not sure what you mean about your question about how its stored on disk. Its just on the hard drive really.

Any comments much appreciated

Mel

Reply With Quote
  #11  
Old January 15th, 2004, 10:32 AM
Daytona955i Daytona955i is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Daytona955i User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
If you have any access on the machine you should be able to install a module. All you need to do is tell your perl script where it is.

Reply With Quote
  #12  
Old January 15th, 2004, 10:41 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,509 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 17 h 57 m 58 sec
Reputation Power: 1322
Quote:
Originally posted by ffenics

ishid, unfortunately I dont have the Net::FTP module installed and I dont have permission to do so (seeing as this is a work machine). Thanks for the thought though. Do you know of any thing else that might work that doesnt require installing anything?


Here's a quickie on installing modules without root access.

Reply With Quote
  #13  
Old January 16th, 2004, 05:49 AM
ffenics's Avatar
ffenics ffenics is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: England. UK
Posts: 12 ffenics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, and thanks for all the help so far. It's much appreciated.

I followed the instructions on how to install a module without root access and wrote a little perl script to check it out, very similar to what ishnid
suggested but, now when I try to run it, I get the following error message:

Code:
 Can't locate object method "new" via package "Net::FTP::A" at <my directory path>//Net/FTP.pm line 946


Could anyone please tell me what this might mean and how to fix it? Thanks

Mel

Last edited by ffenics : January 16th, 2004 at 05:52 AM.

Reply With Quote
  #14  
Old February 5th, 2004, 10:29 AM
llccoo's Avatar
llccoo llccoo is offline
Perl4Life
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: New York
Posts: 471 llccoo User rank is Corporal (100 - 500 Reputation Level)llccoo User rank is Corporal (100 - 500 Reputation Level)llccoo User rank is Corporal (100 - 500 Reputation Level)llccoo User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 13 h 53 m 35 sec
Reputation Power: 7
Send a message via AIM to llccoo