perl - copying files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl - copying files
# 1  
Old 12-13-2007
perl - copying files

Folks, here is my code:

I am a serious newbie, why doesn't this make copies of my files? I dont get any errors, the files are just not created.

Your help is appreciated

#!/usr/bin/perl

use File::Copy;

$PWD = `pwd`;
$REPORTDIR = "/usr/local/tripwire/tfs/report";

chdir $REPORTDIR;

for (`ls /usr/local/tripwire/tfs/report | grep 2007`)
{
copy("$_","copyfile-$_");
}
# 2  
Old 12-13-2007
First, make sure $_ in the loop is really populated with what you expected to get.

Second, capture all the errors. You called copy() but do not follow by die(), so you will never know why the copy failed. Otherwise, the error should tell you why.

File::Copy - perldoc.perl.org
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL - Copying ONLY files from one dir to another

I'm writing a Perl script which has its 1st step as to copy files from one directory to another directory. The Source directory has got files with extension, without extension, directories etc. But I want to copy ONLY files with no extension. The files with extensions and directories should not get... (2 Replies)
Discussion started by: jhamaks
2 Replies

2. Shell Programming and Scripting

Perl : copying only the latest file to other directory

In linux.. In a directory there are 3 files which I want to copy only the latest file (ls -ltr myfiles*.txt|tail -1) to other directory in perl? Could anyone please help me with the code? Regards, J (1 Reply)
Discussion started by: scriptscript
1 Replies

3. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

4. Shell Programming and Scripting

Help needed in perl; moving or copying the variables

Hi All, I have a perl script blc.pl; i have five variables a,b,c,d and e in this script. Now I want to copy the values of these variables into a data file,say abc.dat.. Can anybody please tell me how to do this? Any help is appreciated.. Thanks in advance (2 Replies)
Discussion started by: puneetkanchi
2 Replies

5. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

6. Shell Programming and Scripting

Perl-opening a file then copying files

Good morning guys!! Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over. The flow should be messages-->messages1-->messages2. Kind of like a log... (1 Reply)
Discussion started by: bigben1220
1 Replies

7. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

8. Solaris

Copying Files

Hi, I understand that to copy files across server, the feasible way will be using scp command. Am I right? What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well? ... (3 Replies)
Discussion started by: user50210
3 Replies

9. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

10. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies
Login or Register to Ask a Question