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]

Reply via email to