Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Oct 1998 23:06:46 -0400
From:      Norman C Rice <nrice@emu.sourcee.com>
To:        Sue Blake <sue@welearn.com.au>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: ftp get filenames with spaces and junk text
Message-ID:  <19981012230646.A29402@emu.sourcee.com>
In-Reply-To: <19981013053326.50449@welearn.com.au>; from Sue Blake on Tue, Oct 13, 1998 at 05:33:26AM %2B1000
References:  <19981012175615.48311@welearn.com.au> <19981012105901.A26212@emu.sourcee.com> <19981013053326.50449@welearn.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 13, 1998 at 05:33:26AM +1000, Sue Blake wrote:
> On Mon, Oct 12, 1998 at 10:59:01AM -0400, Norman C Rice wrote:
> > On Mon, Oct 12, 1998 at 05:56:15PM +1000, Sue Blake wrote:
> > > How do I get oddly named files from a macintosh ftp server to land on
> > > my FreeBSD disk with a decent file name? Here's some examples:
> > > 
> > > 981011 Small Bus. Sue
> > > Extra bits for System.sit
> > 
> > You can try the ncftp2/3 port -- with it you can use the tab key
> > to complete file names. An alternative method would be to use
> > a graphical FTP client and click on the file names. Using the
> > standard FTP client you can try using wildcard characters 
> > (`*' and `?') to complete the file names, but YMMV.
> 
> The plain ftp client does tab completion, wildcards, and command
> history too. Some ftp commands rely on the capabilities of the remote
> machine, and others the local machine. None of the above features work
> on a remote ftp server that thinks all the world is a mouse.
> 
> But that's not my problem. Getting the file off the macintosh is OK.
> The only way is 'get "silly name of file"', no matter what client I use.
> 
> Then later, on my own machine I go
>   mv "silly name of file" newname
> or
>   mv sil* newname
> so that I don't have to deal with the spaces etc in the original name.
> For one or two files, that's easy enough.
> 
> For lots of files, I could learn how to run a script on my machine to
> rename them afterwards. 

Here's a script that changes spaces to underscores.

#!/bin/sh

for f in *; do
  n=`expr "xxx$f" : 'xxx\(.*\)' | tr -s '[ ]' '[_]'`
  /bin/mv "$f" "$n"
done

> But after reading the ftp man page, I see there
> is a better method and I want to use it.
> 
> The standard ftp client has a feature which can be activated to rename
> all files automatically as it writes them to the local disk. I want to
> learn how to use this feature of ftp. It is simple, and documened, but
> I don't understand the syntax.

Just use the FTP client's `ntrans' command as follows (this will
change file name spaces to underscores).

  ntrans " " "_"

before getting the files from the remote system.
-- 
Regards,
Norman C. Rice, Jr.

> 
> Commands which depend on a cooperative ftp server are futile.
> It is fairly easy to get the files to here from the server.
> There are unixy ways to deal with the names after files arrive here.
> I have an ftp client that can do this renaming on the fly.
> I want to know how to use the ftp client to do this.
> 
> Why? Because it's there, because I'm perverse, an idiot, stubborn,
> curious, it seems like a fun thing to do, and because someone else
> might find it handy too.
> 
> 
> -- 
> 
> Regards,
>         -*Sue*-


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981012230646.A29402>