Sponsored Content
Full Discussion: Perl automated file transfer
Top Forums Shell Programming and Scripting Perl automated file transfer Post 302382544 by lastrider on Thursday 24th of December 2009 08:05:14 AM
Old 12-24-2009
Hi, yeh I guess I do require raw help. Thanks for the reply though.

---------- Post updated 12-24-09 at 08:05 AM ---------- Previous update was 12-23-09 at 03:04 PM ----------

Hi again,

Sorry to double post, I've actually come back this time with a script which I'm having a little trouble with.

I have this so far, intending to do what I set out in my original post:

Code:
#!/usr/bin/perl

use strict;
use warnings;
use Net::FTP;
use Net::Netrc;
my $server="remote.ip.address";
my $pageid = "none";
my $pager = "/usr/local/bin/pager";
my $ftpid = "username";
my $pass = "password";
my $remote_cwd = "/srcds_l/cstrike/bin";
#my @files = ls("/srcds_l/cstrike/bin");
my $local_cwd  = "/home/my11969/www/test";

my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3) or
    die (exec "$pager $pageid \"$server: ftp cannot connect: $@\"") ;

$ftp->login("$ftpid","$pass") or
    die (exec "$pager $pageid \"ftp cannot login.\"") ;

$ftp->ascii or
    die (exec "$pager $pageid \"ftp failed binary mode.\"") ;

## get multile files if they exist.

$ftp->cwd($remote_cwd) or die "Can't cd to '$remote_cwd'\n";

#chdir $local_cwd or die "Can't cd to '$local_cwd'\n";

my @files = $ftp->ls($remote_cwd);

for (@files) {
    $ftp->get("$_","$local_cwd/$_") if -f $_;
}

$ftp->quit;

Though when I execute it, I get the following:

Code:
Net::FTP>>> Net::FTP(2.77)
Net::FTP>>>   Exporter(5.58)
Net::FTP>>>   Net::Cmd(2.29)
Net::FTP>>>   IO::Socket::INET(1.29)
Net::FTP>>>     IO::Socket(1.29)
Net::FTP>>>       IO::Handle(1.25)

Net::FTP=GLOB(0x88e7118)<<< 220 (vsFTPd 2.0.5)
Net::FTP=GLOB(0x88e7118)>>> USER ******
Net::FTP=GLOB(0x88e7118)<<< 331 Please specify the password.
Net::FTP=GLOB(0x88e7118)>>> PASS ....
Net::FTP=GLOB(0x88e7118)<<< 230 Login successful.
Net::FTP=GLOB(0x88e7118)>>> TYPE A
Net::FTP=GLOB(0x88e7118)<<< 200 Switching to ASCII mode.
Net::FTP=GLOB(0x88e7118)>>> CWD /srcds_l/cstrike/bin
Net::FTP=GLOB(0x88e7118)<<< 250 Directory successfully changed.
Net::FTP=GLOB(0x88e7118)>>> PASV
Net::FTP=GLOB(0x88e7118)<<< 227 Entering Passive Mode (85,234,148,14,104,92)
Net::FTP=GLOB(0x88e7118)>>> NLST /srcds_l/cstrike/bin
Net::FTP=GLOB(0x88e7118)<<< 150 Here comes the directory listing.
Net::FTP=GLOB(0x88e7118)<<< 226 Directory send OK.
Net::FTP=GLOB(0x88e7118)>>> QUIT
Net::FTP=GLOB(0x88e7118)<<< 221 Goodbye.

It looks like it lists the directory but nothing is returned or nothing is downloaded.

I wish to download (get) everything in the said $remote_cwd directory into the $local_cwd directory. Am I missing something here? I'm just bamboozled.

Any help appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl scirpt for automatic file transfer

Hi , can any one help me with a perl script for automating file transfer ? At each step i need to check for the success or failure . I am trying to connect to the target system for a specified number of times.if it doesnt connect even after 3 retries then the script should exit. and i have to... (8 Replies)
Discussion started by: sveera
8 Replies

2. Shell Programming and Scripting

Data transfer from DB2 to Sybase using Perl?

Hi, Good Morning everybody. I need to write a perl script which will get some data from DB2 table and then put it into Sybase table. I have the experience in Oracle and Unix but new to these perl, DB2 and Sybase technologies. Appreciate if any one can suggest with a sample code. Thanks... (1 Reply)
Discussion started by: rajus19
1 Replies

3. Shell Programming and Scripting

moving a file to a new folder and automated ftp

how to move a file to a different folder after an automated FTP . (1 Reply)
Discussion started by: dineshr85
1 Replies

4. UNIX and Linux Applications

Automated file transfer

I want to automate the file transfer from a remote site to my pc over a WAN. Can anyone please suggest an industry standard secure file transfer tool for a windows environment? I am looking for an industry accepted, more secure than traditional FTP. Thanks! (1 Reply)
Discussion started by: damienjine
1 Replies

5. Shell Programming and Scripting

C, sh, perl, system(): Can't transfer a return code appropriately: help, pls

I am using a perl-script from C-code, executing it by the 'system(..)' comand. The problem is to return the perl-return code to the C correctly. Default the 'system()' shell is Bourne: sh My try: (perl_src.c_pl - the perl script; t_sys - C-program with system() call (I will show it... (7 Replies)
Discussion started by: alex_5161
7 Replies

6. Shell Programming and Scripting

Automated script to take 1000 records from the file every week.

I have a file having n number of records .i want first 1000 records from the file and store in temporary file to process on sunday. I want script should should automatically take the next 1000 records for processing on next sunday. can we do it using head and tail head -1000 | tail... (2 Replies)
Discussion started by: sonam273
2 Replies

7. UNIX for Advanced & Expert Users

perl script to transfer newly generated files by scp

Hi all, I have root directory on server 1 say A and having sub directory B now my application generates output files and put in sub directory B. now i need to transfer these files from server1 to server2 by scp which is having same directory structure A and sub directory B I have tried... (2 Replies)
Discussion started by: tushar_spatil
2 Replies

8. Shell Programming and Scripting

How to transfer file from one PC to another using PERL?

Hi All I have two PC connected with each other via LAN cable. In one of the PC the Perl is installed. What I want to do is transfer the data from one PC to another via Perl. Is it possible to do this. ---------- Post updated at 11:31 PM ---------- Previous update was at 07:01 AM ----------... (10 Replies)
Discussion started by: parthmittal2007
10 Replies

9. Shell Programming and Scripting

Need help for automated pickup of file based on a priority

Hi experts, I am facing a problem right now.I have to automate the pickup of files based on a priority.The scenario is as below: 1) There will be files from Mon-Fri with Mon file being named as abc_def_01_YYYYMMDD and Tue file being abc_def_02_YYYYMMDD and so forth till Friday's file which... (1 Reply)
Discussion started by: vikramgk9
1 Replies

10. UNIX for Beginners Questions & Answers

Automated File Transfer Script

We are receiving data feed files in SFTP location daily. so the folder structure in SFTP location is abc/def/studyname_1/outbound/zipped files So we will be getting different studies and for each study a folder is created abc/def/studyname_2/outbound/zipped files , ... (7 Replies)
Discussion started by: Sidhant
7 Replies
IO::All::FTP(3pm)					User Contributed Perl Documentation					 IO::All::FTP(3pm)

NAME
IO::All::FTP - Extends IO::All to FTP URLs SYNOPSIS
use IO::All; "hello world " > io('ftp://localhost/test/x'); # save to FTP io('ftp//example.org/pub/xyz') > io('xyz'); # GET to file # two ways of getting a file with a password: $content < io('ftp://me:secret@example.org/xyz'); $content < io('ftp://example.org/xyz')->user('me')->password('secret'); DESCRIPTION
This module extends IO::All for dealing with FTP URLs. Note that you don't need to use it explicitly, as it is autoloaded by IO::All whenever it sees something that looks like an FTP URL. METHODS
This is a subclass of IO::All::LWP. The only new method is "ftp", which can be used to create a blank IO::All::FTP object; or it can also take an FTP URL as a parameter. Note that in most cases it is simpler just to call io('ftp//example.com'), which calls the "ftp" method automatically. OPERATOR OVERLOADING
The same operators from IO::All may be used. < GETs an FTP URL; > PUTs to an FTP URL. SEE ALSO
IO::All::LWP, IO::All, LWP. AUTHORS
Ivan Tubert-Brohman <itub@cpan.org> and Brian Ingerson <ingy@cpan.org> COPYRIGHT
Copyright (c) 2007. Ivan Tubert-Brohman and Brian Ingerson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.10.0 2007-03-29 IO::All::FTP(3pm)
All times are GMT -4. The time now is 12:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy