Tony McGuinness wrote:
> 
> Hi there,

Hello,

> I am getting the following:
> 
> cannot execute ftpscr Illegal seek at ./getfile.pl line 31.
> 
> from a simple Perl script (below). The system command is returning
> the error and the pathname points to the current directory. I cannot
> seem to find any documentation on this error. Has anyont encountered
> the same.

You do realize that the Net::FTP module that comes with perl would be a
lot easier.


> #!/usr/local/bin/perl -w
> 
> use strict;
> use Cwd;
> 
> my $hostname = "barney";
> my $username = "mimsp";
> my $password = "mimsp";
> my $sourcedir = "../work";
> my $destdir = "../work";
> my $file = "MSF099";
> my $command = "upload";
> my $Basedir = cwd();
> my $args;
> 
> open FTPSCR, "> ftpscr";

You should _always_ test the success or failure of open().

open FTPSCR, '> ftpscr' or die "Cannot open ftpscr: $!";


> print FTPSCR "#!/usr/bin/ksh\n";
> print FTPSCR "ftp -n -v $hostname << EOF > 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";
> print FTPSCR "EOF\n";
> 
> print "$Basedir\n";
> system("chmod +x ftpscr");

You do realize that perl _has_ a chmod function?

perldoc -f chmod


> $args = "$Basedir/ftpscr";
> system("/usr/users/tony/perl/proj1/ftpscr") or die "cannot execute ftpscr
> $!";

You should read the documentation on the proper way to use system() and
get relevant error messages from using it.

perldoc -f system


> #unlink "ftpscr";
> 
> #system($command);
> =====================================================================
> DISCLAIMER
> 
> 1. The information contained in this E-mail is confidential.

Then why are you posting it to this mailing list?



#!/usr/local/bin/perl -w
use strict;
use Net::FTP;

my $hostname  = 'barney';
my $username  = 'mimsp';
my $password  = 'mimsp';
my $sourcedir = '../work';
my $destdir   = '../work';
my $file      = 'MSF099';

chdir $destdir or die "Cannot cd to $destdir: $!";

my $ftp = Net::FTP->new( $hostname ) or die "Couldn't connect to
$hostname: $@\n";

$ftp->login( $username, $password ) or die "Cannot log in to
$hostname\n";
$ftp->binary or die "Cannot set binary mode\n";
$ftp->cwd( $sourcedir ) or die "Cannot change to directory
$sourcedir\n";
$ftp->get( $file ) or die "Cannot get $file\n";
$ftp->quit;

__END__


John
-- 
use Perl;
program
fulfillment

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

Reply via email to