|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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. |
|
#2
|
|||
|
|||
|
You can use sleep(n) where n is number of seconds to wait.
|
|
#3
|
||||
|
||||
|
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 ![]() |
|
#4
|
||||
|
||||
|
Quote:
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 |
|
#5
|
||||
|
||||
|
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 ![]() |
|
#6
|
||||
|
||||
|
Mel,
Where are you downloading the file to? The same directory as the script? --Ax |
|
#7
|
||||
|
||||
|
Hi Axweildr
Yes, I am downloading the file to the same directory as the script. Why? Might that cause a problem? Mel ![]() |
|
#8
|
||||
|
||||
|
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 |
|
#9
|
||||
|
||||
|
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;
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
|
#10
|
||||
|
||||
|
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 ![]() |
|
#11
|
|||
|
|||
|
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.
|
|
#12
|
||||
|
||||
|
Quote:
Here's a quickie on installing modules without root access. |
|
#13
|
||||
|
||||
|
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. |
|
#14
|
||||
|
||||