473,587 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copying files or a directory

51 New Member
hi,
I have got a list of files in a "list" as follows:
Expand|Select|Wrap|Line Numbers
  1.     foreach(@arr)
  2.     { 
  3.             copy ("$_", "/home/pavan/tmp") or die "copy failed: $! ";
  4.      }
  5.  
The path where the files are stored is /home/pavan/perl.
I need to copy all the files in perl directory to the temporary directory
"tmp" as in the copy statement. For that i used a package File::Copy.
I am able to print the files with print "$_ \n";
But unfortunately the copy statement is not working . I am not getting an error either.
So could u tell me how to copy all the files in perl to tmp directory? Also is there any method to copy the perl directory as a whole to tmp directory?

Thanks & Regards,
pavan.
Jun 17 '08 #1
5 2090
numberwhun
3,509 Recognized Expert Moderator Specialist
You say you can print the file names with the print statement, but does the file names include the full path? If you are executing the script from somewhere other than the directory where all of the files are located, then you will need to include the full path with something like this:

Expand|Select|Wrap|Line Numbers
  1. foreach(@arr)
  2. {
  3. copy ("/home/pavan/perl/$_", "/home/pavan/tmp") or die "copy failed: $! ";
  4. }
  5.  
Oh, and please use code tags next time when including code.

Regards,

Jeff
Jun 17 '08 #2
pavanponnapalli
51 New Member
hi ,
all the files which i like to copy in /tmp directory are in the directory /perl itself . so i used $_ directly without giving full path . I also tried the way just u have told me . I had given the full path. But it has not worked . Also there is no error. So, is there any alternative to do the above work?

Thanks & Regards,
pavan
Jun 17 '08 #3
KevinADC
4,059 Recognized Expert Specialist
hi,
I have got a list of files in a "list" as follows:
Expand|Select|Wrap|Line Numbers
  1.     foreach(@arr)
  2.     { 
  3.             copy ("$_", "/home/pavan/tmp") or die "copy failed: $! ";
  4.      }
  5.  
The path where the files are stored is /home/pavan/perl.
I need to copy all the files in perl directory to the temporary directory
"tmp" as in the copy statement. For that i used a package File::Copy.
I am able to print the files with print "$_ \n";
But unfortunately the copy statement is not working . I am not getting an error either.
So could u tell me how to copy all the files in perl to tmp directory? Also is there any method to copy the perl directory as a whole to tmp directory?

Thanks & Regards,
pavan.

I think the problem is you are copying all the files in the perl directory to the pavan directory into a file named tmp.

Assuming you are in the directory where the files are to be copied from:

Expand|Select|Wrap|Line Numbers
  1.     foreach(@arr)
  2.     { 
  3.             copy ("$_", "/home/pavan/tmp/$_") or die "copy failed: $! ";
  4.      }
  5.  
copy() takes two arguments, a file to copy from and a file to copy to.
Jun 17 '08 #4
numberwhun
3,509 Recognized Expert Moderator Specialist
I think the problem is you are copying all the files in the perl directory to the pavan directory into a file named tmp.

Assuming you are in the directory where the files are to be copied from:

Expand|Select|Wrap|Line Numbers
  1.     foreach(@arr)
  2.     { 
  3.             copy ("$_", "/home/pavan/tmp/$_") or die "copy failed: $! ";
  4.      }
  5.  
copy() takes two arguments, a file to copy from and a file to copy to.
Ouch! I completely missed the lacking "/" that was missing after the "tmp" dir name. C'est la vie.

Jeff
Jun 17 '08 #5
pavanponnapalli
51 New Member
Ouch! I completely missed the lacking "/" that was missing after the "tmp" dir name. C'est la vie.

Jeff
hi,
i think the files are not copying bcoz tmp is a directory in which system generated temporary files are stored? Can we copy files into a directory which contains system generated files?
Jun 18 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3633
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore my settings if my profile became tampered with or corrupt. Is there any sample code available out there? -Robert
5
6047
by: Ian Davies | last post by:
Hello I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your...
10
7822
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in 'to.txt' I specify where to copy it - After I read content of 'to.txt' I create one more subfolder named by current date and thats where everything gets...
17
16124
by: Kerr | last post by:
Hi all, I am sure that this is quite simple but can't find any good examples anywhere. I need a method of copying multiple files from a source directory to a destination directory. The file format of the files will be mixed but I will be only interested in copying files with a particular extention (i.e. *.csv). I'm using VB.NET and...
3
1226
by: Phil Galey | last post by:
In VB.NET, is there any way to copy a directory and all its contents to a new location using io.Directory or io.DirectoryInfo etc. without having to import the Scripting.FileSystemObject? io.Directory and DirectoryInfo only seem to have a Move command, but what about copying?
4
15414
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the tables in it automatically? I was hoping to have the tables (the frm files) included in a subdirectory and when required, just create a new schema...
6
1986
by: Jim Heavey | last post by:
I have written a little application which copies files from one location to another location. Before it copies the file, it ensure the directory for both the from and to locations is valid. It also ensures that the from file exists. All that being successful, it attempts to copy the file, but each time I get an exception in which the text...
2
8014
by: Jerad Rose | last post by:
I have a fairly simple C# console app which copies files from a network folder to a local folder. When the app resides on my local C: drive, it runs just fine. However, when the app resides on a network drive, copying the same files from the same source drive and to the same destination drive, it gives me the following exception: ...
2
2668
by: Alan Bak | last post by:
HI I am running Active Perl on a Windows XP machine. I am hoping to get some advise on a strategy to monitor and copy files that are arriving in a directory and need to be copied to a second location. Files will arrive at the rate of one every 2 to 4 seconds into a directory immediately below the parent. The number of files written to each...
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.