How copy dir when there is a space betwwen

C

cyrusgreats

I have gui page that reads a list of directory and print directories
(just names not full path) into scrolling_list on the gui page than
from there I choose the dir/name and want to copy the directory to the
other page. The problem I ran into problem, some of the directories
have space between like "I am a dirtectory, when I want to copy the
directory it can't find the orign of dir, any idea how to get around
this...thanks in advance..
Here is a code to read directory and copy ones!

$orign = "../origin/";
$target = ''../target/";

opendir(DIR, $orign) or die "$!";
opendir(SUB, $target) or die "$!"; # here in this dir there many
dirctories some of or space or special chrac between

foreach $dir (@DIR) {
opendir(R, $orign);
@subdir = grep(/^i/, sort readdir(SUB));
}



# here print those files from @subdir to the gui/page
# user select one of the dir or name (may have space between)
# copy the name/dir to other location

$copy = $MYDATA{copy};
$target = ''../target/$copy";

`cp -R -f $orig $target`;

# here I'm getting error "No such file or directory"
# due to the space betwwen target
 
B

Brian McCauley

I have gui page that reads a list of directory and print directories
(just names not full path) into scrolling_list on the gui page than
from there I choose the dir/name and want to copy the directory to the
other page. The problem I ran into problem, some of the directories
have space between like "I am a dirtectory, when I want to copy the
directory it can't find the orign of dir, any idea how to get around
this...thanks in advance..
Here is a code to read directory and copy ones!

$orign = "../origin/";
$target = ''../target/";

opendir(DIR, $orign) or die "$!";
opendir(SUB, $target) or die "$!"; # here in this dir there many
dirctories some of or space or special chrac between

foreach $dir (@DIR) {
opendir(R, $orign);
@subdir = grep(/^i/, sort readdir(SUB));
}

# here print those files from @subdir to the gui/page
# user select one of the dir or name (may have space between)
# copy the name/dir to other location

$copy = $MYDATA{copy};
$target = ''../target/$copy";

`cp -R -f $orig $target`;

See FAQ: What's wrong with using backticks in a void context?
# here I'm getting error "No such file or directory"
# due to the space betwwen target

system('cp','-R','-f',$orig,$target);

If you really want to involve /bin/sh then you can qoutemeta().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top