delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/23/14:40:31

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: Handling special characters (\/:*?"<>|) gracefully
Date: Tue, 23 May 2006 13:40:20 -0500
Message-ID: <2ED63F31975E1E428B3732A68923F480ECA6FC@rain.scur.com>
From: "Hicks,Mike" <Mike_Hicks AT securecomputing DOT com>
To: <cygwin AT cygwin DOT com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k4NIeUwS032465

Hi,
 
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 
there...).
 
Thanks.
 
-- 
Mike Hicks [mhicks AT securecomputing DOT com]
Associate Test Engineer
Secure Computing, St. Paul, MN



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019