Copy using system

Copy using system

am 01.10.2007 23:30:39 von lerameur

hello,
I wrote a small script in perl.
this is the line that is buggy:

mkdir ("/ins/$Out_directory/aux", 0777);
system(`cp -p * /dir/$Out_directory/aux `);

I use the above command , the files do get copied, but the command do
not exit once it is finished. It just hangs there and do not proceed,
I need to hit ctlr-Z . no error message. what is wrong


ken

Re: Copy using system

am 01.10.2007 23:44:41 von glex_no-spam

lerameur wrote:
> hello,
> I wrote a small script in perl.
> this is the line that is buggy:
>
> mkdir ("/ins/$Out_directory/aux", 0777);
> system(`cp -p * /dir/$Out_directory/aux `);
>
> I use the above command , the files do get copied, but the command do
> not exit once it is finished. It just hangs there and do not proceed,
> I need to hit ctlr-Z . no error message. what is wrong

1. Check if mkdir was successful.
2. Use double-quotes.

Re: Copy using system

am 02.10.2007 01:52:37 von Keith Keller

On 2007-10-01, lerameur wrote:
>
> mkdir ("/ins/$Out_directory/aux", 0777);
> system(`cp -p * /dir/$Out_directory/aux `);

This is really not doing what you probably expect. You're sending the
stdout of the cp command to system! There is likely no stdout, so this
happens:

> I use the above command , the files do get copied, but the command do
> not exit once it is finished. It just hangs there and do not proceed,
> I need to hit ctlr-Z . no error message. what is wrong

So, either use system or use backticks, but definitely not both in the
same command.

--keith

--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

Re: Copy using system

am 02.10.2007 02:12:02 von jurgenex

lerameur wrote:
> I wrote a small script in perl.
> this is the line that is buggy:
>
> mkdir ("/ins/$Out_directory/aux", 0777);
> system(`cp -p * /dir/$Out_directory/aux `);

Why are you using the output of the cp command as the argument for system()?
I highly doubt that is what you meant to do.

Anyway, if you want to copy files then you may want to check the File::Copy
module.

jue

Re: Copy using system

am 02.10.2007 08:54:31 von Joe Smith

lerameur wrote:
> system(`cp -p * /dir/$Out_directory/aux `);
>
> I use the above command , the files do get copied, but the command do
> not exit once it is finished. It just hangs there and do not proceed,
> I need to hit ctlr-Z . no error message. what is wrong

We already gave you the answer to your posting of 28 Sep 2007 13:07:08.
(Message-ID: <1191010028.753764.76290@d55g2000hsg.googlegroups.com>)
Were you not paying attention?



You screwed up by using `` instead of "". You need

system("cp -p * /dir/$Out_directory/aux");

or

system("cp -p * /dir/$Out_directory/aux") == 0 or warn
"'cp' failed with error code ",($?>>8),", signal ",($?&0xff);

-Joe

Re: Copy using system

am 03.10.2007 01:30:19 von rvtol+news

Jürgen Exner schreef:

> if you want to copy files then you may want to check the
> File::Copy module.

Or maybe not:
http://www.google.co.uk/search?q=abigail+File%3A%3ACopy

"Another of those Perl modules that should never have been made."

--
Affijn, Ruud

"Gewoon is een tijger."