Sponsored Content
Full Discussion: uncompress a file and ftp
Top Forums Shell Programming and Scripting uncompress a file and ftp Post 302338145 by namishtiwari on Monday 27th of July 2009 06:43:47 AM
Old 07-27-2009
uncompress a file and ftp

Hi Experts,

Here is my piece of code--

Code:
#!/usr/bin/perl
use Net::FTP;
#use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
use IO::File ;
    
print "Retrieving file from abc.com...\n";
$loginip='123.456.0.23';
$loginid='nt1234';
$loginpaswd='defgsljf';
($sec,$min,$hour,$mday,$mon,$year)=(localtime(time))[0,1,2,3,4,5];
$time_stamp= "_" . (1900+$year) . "_" . ($mon+1) . "_" . ($mday) . "_" . $hour . "_" . $min . "_". $sec;
printf "time stamp = $time_stamp\n";


unless(-d "temp")
{
mkdir("temp");
}
if( -d "temp")
{
chdir("temp");
}

$ftp = Net::FTP->new(($loginip), Debug => 0)
or die "Cannot connect to abc.com: $@ \n";

$ftp->login($loginid,$loginpaswd)
or die "Cannot login ", $ftp->message;

$source_dir="/abc/nali05/";

$ftp->cwd($source_dir)
or die "Cannot change working directory ", $ftp->message;


$ftp->binary || die "Unable to set mode to binary. ", $ftp->message;

@list=$ftp->ls();
printf "list = \n";
print @list;
foreach $file (@list)
{
#unzip "$file" => "$source_dir"' or die "unzip failed: $UnzipError\n";

#if($file =~ m/namish*/i)
#{
$ftp->get($file) or die "get failed ", $ftp->message;
#rename($file,"${file}_${time_stamp}");
$ftp->delete ($file) or die "rm -rf failed ", $ftp->message;
#}
}


$ftp->quit;

When i use my code without uncompress part it works fine. But i want to uncompress it first and choose files and ftp only those files.
When i run the script i get this error--

Code:
C:\Perl Script>perl ftp1.pl
Can't locate IO/Uncompress/Unzip.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/
site/lib .) at ftp1.pl line 3.
BEGIN failed--compilation aborted at ftp1.pl line 3.

I searched for the uncompress aprt and tried that but that seem to be working. Kindly give some suggestions as how to get rid of this....

Thanks
NT

Last edited by namishtiwari; 07-28-2009 at 04:52 AM.. Reason: commented the uncompress part
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to uncompress .zip file?

Hi all, Can anyone tell me what tools / command can use to uncompress those *.zip file in HP-UX, thx. Bgds, Gordon (7 Replies)
Discussion started by: fonggo
7 Replies

2. Shell Programming and Scripting

ftp/Uncompress error.

I am getting a 'corupt index' error when I uncompress a file that has been ftped to HP-UX server from a Solaris box. I am actually ftp about 5 files and am able to Uncompress 4 of the files however I get a 'Corrupt Index' error when one of the fifth file is being Uncompressed. Any help :confused: (2 Replies)
Discussion started by: oracle8
2 Replies

3. UNIX for Dummies Questions & Answers

How to get to a file and uncompress it

I did an ftp to copy a tar file from a main server area to the backup server area. I need to get that tar file to uncompress it in backup server. How do I go about it. Please any suggesstion will be greatly appreciated (1 Reply)
Discussion started by: nkem22
1 Replies

4. UNIX Desktop Questions & Answers

file zip,rar,tar,compress,uncompress,unzip,unrar

i want know how to compress and uncompress file using unix, compress uncompress,zip,unzip,rar,unrar,how its work and more about this.:confused: (1 Reply)
Discussion started by: ismael xavier
1 Replies

5. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

6. Shell Programming and Scripting

Compress in UNIX ftp the uncompress in windows server

Hi all, I need a shell script that will compress all the files in the UNIX box say /output/foldre/OUT/*.out. 1. I need to compress all the .out files present in this path. 2. The compressed files shuld be FTPed to Windows server say C:\Myfiles 3. Then the FTPed files should be... (3 Replies)
Discussion started by: Codesearcher
3 Replies

7. Programming

Uncompress a gzip and bzip file using java on unix solaris environment

Hi, I need to uncompress a gzip and bzip file using java on unix solaris environment. I also need to retreive the header information of the file inorder to differentiate between gzip and bzip file. Please help Pooja (0 Replies)
Discussion started by: wadhwa.pooja
0 Replies

8. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

9. Shell Programming and Scripting

Uncompress and ftp a file

i have a compressed file, i need to ftp this file to remote server. while ftp i should uncompress and send, but the uncompressed file shouldn't write in the local server file system. is there any options how to do this using a named pipes in ftp?? greatly appreciate your suggestions? Thanmks (2 Replies)
Discussion started by: Fakru.y
2 Replies

10. UNIX for Dummies Questions & Answers

scp and uncompress on the file?

Hi, Is there any way to do scp and uncompress on the fly? At the moment, I am doing scp and then running uncompress of the .Z files in the background. I am wanting to be able to do scp and then have the uncompress the .Z file in the background. Any advice much appreciated. Thanks in... (3 Replies)
Discussion started by: newbie_01
3 Replies
FTP_SITE(3)								 1							       FTP_SITE(3)

ftp_site - Sends a SITE command to the server

SYNOPSIS
bool ftp_site (resource $ftp_stream, string $command) DESCRIPTION
ftp_site(3) sends the given SITE command to the FTP server. SITE commands are not standardized, and vary from server to server. They are useful for handling such things as file permissions and group membership. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $command - The SITE command. Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Sending a SITE command to an ftp server <?php // Connect to FTP server $conn = ftp_connect('ftp.example.com'); if (!$conn) die('Unable to connect to ftp.example.com'); // Login as "user" with password "pass" if (!ftp_login($conn, 'user', 'pass')) die('Error logging into ftp.example.com'); // Issue: "SITE CHMOD 0600 /home/user/privatefile" command to ftp server if (ftp_site($conn, 'CHMOD 0600 /home/user/privatefile')) { echo "Command executed successfully. "; } else { die('Command failed.'); } ?> SEE ALSO
ftp_raw(3). PHP Documentation Group FTP_SITE(3)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy