[PERL] Cannot stat or move filename - £££F3AERO££.txt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [PERL] Cannot stat or move filename - £££F3AERO££.txt
# 1  
Old 05-13-2011
[PERL] Cannot stat or move filename - £££F3AERO££.txt

Scenario: Users drop files into a directory which is regularly polled by my PERL process. On detecting a file my process will move it from the poll dir to a working directory. A user created a file with a £ symbol in the filename and my process now fails.

e.g £££F3AERO££.txt

/sbcimp/run/pd/perl/32-bit/5.8.8/bin

Code:
opendir (POL, $polldir ) 
while( (my $fName = readdir(POL))){
next unless ( $fName =~ /txt$/ );
my ($filename, $Symbol, $bSymbol);
$logger->info("File Name - $fName");
$filename = qq($polldir/$fName);
unless ( -f "$filename" ) {
$logger->logdie("Cannot Stat File"}
}

I can handle most badly formed filenames but the £ has flumoxed me. Any suggestions . Thanks P.S I have messed around with encode/decode utf8 but no luck. The file does exist and I do have permission. Ta.

Last edited by pludi; 05-13-2011 at 09:30 AM..
# 2  
Old 05-17-2011
Maybe PERL is treating it like '#', which is what it is if the 8th bit is lost? You might need some quoting to control it more! Is this file name utf8 or iso8859-1 ? Probably the latter.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract the filename and write to .txt

I'm new to this forum and also to UNIX scripting. I need a command to extract the filename from the path and write to .txt file. Thanks in advance for your guidance. (23 Replies)
Discussion started by: Ram Kumar_BE
23 Replies

2. UNIX for Dummies Questions & Answers

Is "stat: illegal option -- -" an issue with hyphenated filename or flag problem?

Hi. I'm trying to install VMWare Workstation to run a virtual machine on my Mac OS, but running the bundle from bash(xterm) sh VMware-workstation-Full-11.0.0-2305329.x86_64.bundle (as suggested in install guide) comes up with error:stat: illegal option -- - usage: stat Digging... (5 Replies)
Discussion started by: defeated
5 Replies

3. Shell Programming and Scripting

Replacing .dat.gz to .txt.gz in filename

Hi, I tried below method; mv -v /oracle1/scr/tilki/willsendtilkiNew/VOICE-MO_$nfname.gz \ $(echo /oracle1/scr/tilki/willsendtilkiNew/VOICE-MO_$nfname.gz | tr 'dat' 'txt'); nfame variable has the string "dat" . I need to rename files like below; ASIS: 20140902103700_100319.dat.gz... (8 Replies)
Discussion started by: snr_silencer
8 Replies

4. UNIX for Dummies Questions & Answers

Add a new column to txt file containing filename

I would like help adding a new column to a large txt file (~10MB) that contains the filename. I have searched other posts but have not found an adequate solution. I need this extra column so I can concatenate >100 files and perform awk searches on this large file. My current txt file look... (4 Replies)
Discussion started by: kellywilliams
4 Replies

5. UNIX for Dummies Questions & Answers

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (7 Replies)
Discussion started by: johannd
7 Replies

6. Shell Programming and Scripting

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (1 Reply)
Discussion started by: johannd
1 Replies

7. Shell Programming and Scripting

How to unzip Filename.txt.Z

Hii I am having a file in Unix which is filename.txt.Z How can i take of the Z to read the file Please help Regards Laxmi (2 Replies)
Discussion started by: laxmi1166
2 Replies

8. Shell Programming and Scripting

rename multiple filename.45267.txt to >> filename.txt

i have several thousand files and in subdirs that are named file.46634.txt budget.75346.pdf etc i want to remove the number but retain the extension. it is always a 5 digit. thanks. (6 Replies)
Discussion started by: jason7
6 Replies

9. Shell Programming and Scripting

Perl how to move pointer to previous line in a txt file?

I have a text file that has blocks of text. Each block starts with ### and ends with End_###. I wrote a perl script to search a string from line 2 (ignore any line starts with ###) of each block if matched, need to print that whole block. According to the input file in below, it will print... (5 Replies)
Discussion started by: tqlam
5 Replies

10. Shell Programming and Scripting

perl: why the return valure of stat and lstat are the same?

i tried to use stat to get the attributes of a file and a soft link. but the result i got from stat and lstat are the same. say: ln -s f1 soft1 (soft is a soft link , point to f1) if i use > ls -il shows the inode and modify time of soft1 and f1 are different. but the modify... (1 Reply)
Discussion started by: gusla
1 Replies
Login or Register to Ask a Question