Hi Johannes,

Thanks for your response, it now works.

Regards,

Tony

-----Original Message-----
From: Johannes Franken [mailto:[EMAIL PROTECTED]]
Sent: 20 February 2002 20:40
To: Perl List (E-mail)
Subject: Re: Illegal seek


On Tue, Feb 19, 2002 at 12:05:40PM -0000, Tony McGuinness wrote:
> I am getting the following:
> cannot execute ftpscr Illegal seek at ./getfile.pl line 31.

Here's what's wrong with your script:

1.) You forgot to close the file before executing it.
    So the system() would find an empty script or an
    old version from a former run.
2.) You wrote "or" instead of "and" after "system" in line 31,
    so you only got an error message when it worked fine.
    Remember that return values are changed for system 
    (shell success = 0 = perl false, executing stuff after "or")
3.) You supposed $! to hold any error of the LAST child.
    But it does not. It holds the LAST error of ANY childs.
    In your case that was in cwd() which is a dizzy one.

And, apart from that you could have the job done easily with some nice
ftp package, here's another hint:

What you do, is: writing a here_document to another script which is
feeding all the ftp-commands to an ftp child, then call a shell to
open the script, find out that it's for ksh, call ksh to execute it's 
contents, calling ftp... that's opening 5 processes and houndreds of 
files to do 1 simple upload. This is deprecated style, if any.

If at all, better call the ftp this way:

        open FTPSCR "|ftp -n -v $hostname > ftplog\n";
        print FTPSCR "user $username $password\n";
        print FTPSCR "bin\n";
        print FTPSCR "cd $sourcedir\n";
        print FTPSCR "lcd $destdir\n";
        print FTPSCR "get $file\n";
        print FTPSCR "bye\n";
        close FTPSCR;

man perlopentut for more information about communicating to a pipe.

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
=====================================================================
DISCLAIMER

1. The information contained in this E-mail is confidential. 
   It is intended only for the stated addressee(s) and access 
   to it by any other person is unauthorised. 
   If you are not an addressee, you must not disclose, copy, 
   circulate or in any other way use or rely on the information 
   contained in this E-mail. Such unauthorised use may be unlawful. 
   If you have received this E-mail in error, please inform us 
   immediately and delete it and all copies from your system.

2. The views expressed in this E-mail are those of the author, 
    and do not represent the views of AMT-Sybex Group Ltd., its 
    associates or subsidiaries, unless otherwise expressly indicated.
    In the avoidance of doubt, the insertion of the name of AMT-Sybex 
    Group Ltd., its associate or subsidiary under the name of the sender 
    may constitute an express indication that the views stated in the Mail 
    are those of the named company.
=====================================================================
For more information on the AMT Sybex group visit: http://www.amt-sybex.com 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to