anne3294 has asked for the wisdom of the Perl Monks concerning the following question:
i use Suse Linux.
i wanna copy all files listed in file:list4, but they are Chinese files with Chinese file names.
variable $1 and $2 are direcory names, and $3 is the Chinese file name.
almost half of the files are copied successfully, with the code as the follws :
system("cp $spath$1/$2/$3 $tpath$3");
however, if there are space,quotes, brackets, or dash lines in the file names, then the above code won't work.
if i add double quotes to variable $3, like :
system("cp $spath$1/$2/"$3" $tpath$3");
the syntax error messages are :
(Missing operator before $3?)
(Missing operator before " $tpath"?)
so,execution aborted due to compilation errors.
is there anyway to copy files with Chinese names and special characters in Suse Linux?
Thanks for any advise in advance !
-- Anne
<code> #!/usr/bin/perl use Cwd; use strict; use utf8; my $tpath="/tmp/ttmp/"; my $spath="/opt/myfirstbank/uploadDir/"; open(F,"list4") or die "Cannot open list2. $!\n"; while (<F>) { $_=~/^(.*?)\/(.*?)\/(.*?)\s/; system("print $1/$2\n"); system("cp $spath$1/$2/"$3" $tpath$3"); } close F;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to copy files with Chinese names and special characters in Suse Linux?
by moritz (Cardinal) on Jun 16, 2011 at 08:52 UTC | |
by anne3294 (Initiate) on Jun 20, 2011 at 08:19 UTC | |
by moritz (Cardinal) on Jun 20, 2011 at 09:07 UTC | |
by Anonymous Monk on Jun 20, 2011 at 09:30 UTC | |
by anne3294 (Initiate) on Jul 19, 2011 at 01:23 UTC | |
by anne3294 (Initiate) on Jul 15, 2011 at 09:55 UTC |