This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Handling special characters (\/:*?"<>|) gracefully

There are a number of special characters that cannot be used in 
filenames on the NTFS filesystem, this includes backslash (\), slash 
(/), colon (:), asterisk (*), question mark (?), double-quote ("), 
less- and greater-than (<>), and pipe (|).  In contrast, most Unix 
systems only prevent the use of slash characters in filenames 
themselves, since that is used as the separator between levels in 
directory hierarchy.
I like to listen to music while at work, where I run Windows with 
Cygwin.  I periodically like to use 'scp' (secure copy, from the SSH 
suite) to download music from my home computer, where I run Linux.  
Some of my music files at home have special characters in them (in 
particular, colon, question mark, and double-quote have appeared most 
frequently).  When I attempt to use scp to download a file with one of 
these characters in the name, it appears that an open() or write() 
function fails with the error "No such file or directory."
Is there a way to get scp to convert the filename to something that can 
be written to disk?  For example, either removing the characters from 
the filename or converting them to underscores would work fine for me.  
A system-wide option would be great, perhaps controlled by an 
environment variable or two.  Otherwise, each program that can write 
files from foreign sources would have to be rewritten.  It would also 
be an improvement to see a more descriptive error than "No such file or 
directory", though I suppose developers would be hesitant to expand 
upon the standard list of error types.
As a workaround, I find it is easiest to create a zip file on my home 
system with the files I want to transfer, then simply unzip it on my 
work machine.  Cygwin's 'unzip' utility appears to handle this 
situation correctly and will convert unusable characters to 
underscores.  I've tried doing the same thing with a tar file, but 
'tar' exhibits the same problems as 'scp' and will not write files that 
originally had a special character in the name.
Apologies if there's already a good method for handling this situation 
(other than renaming my original files, thanks).  I did a requisite 
Google search and some thumbing through man pages, but didn't come 
across anything (though that doesn't mean there wasn't anything 
Mike Hicks []
Associate Test Engineer
Secure Computing, St. Paul, MN

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]