cp and mv commands (copying/moving only if file does not exist, regardless of the time stamps, for use in a automatic script)

2008-03-27 Thread Darren DeHaven

I need the deprecated mv and cp command parameter "--reply=" to stay.


I've noticed that the parameter "--reply=no" is "deprecated"

" cp: the --reply option is deprecated; use -i or -f instead "


My issue: In a script without user input, I want to copy a file to a 
directory if only the file doesn't already exist, (I don't want to 
overwrite anything), and regardless of the time stamp.


The only way I see to do this is with the deprecated parameter:
"-i --reply=no"

Example:
"cp -i --reply=no foo bar"

This way if bar exist, then foo won't overwrite it.


Thanks,
~Darren

--
This message (including attachments) contains information which is 
confidential and privileged. Unless you are the intended recipient, you 
may not use, copy, disseminate or disclose to anyone the message or any 
information contained in the message.  Proteus submits this email with 
the understanding that it will be held in the strictest confidence and 
will not be used, in whole or in part, for any purpose other than the 
evaluation of Proteus' qualifications without the prior written consent 
of Proteus, Inc.  If you have received the message in error, please 
advise the sender by reply email and delete the message.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.





Re: cp and mv commands (copying/moving only if file does not exist, regardless of the time stamps, for use in a automatic script)

2008-03-27 Thread Eric Blake

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Darren DeHaven on 3/27/2008 3:33 PM:
| I need the deprecated mv and cp command parameter "--reply=" to stay.

But since bash does not implement mv or cp, you've complained to the wrong
list.  This decision has been rehashed a number of times on the
bug-coreutils list, you may want to search the archives for more rationale
why the change was made (hint: the --reply options did not always work
intuitively - they only took effect IF the command was going to prompt in
the first place, and the POSIX rules for when to prompt are pretty hairy).
~ At any rate, I suggest looking into rsync, which can do exactly what you
want and more.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkfsXcwACgkQ84KuGfSFAYCLQwCfXn9qxfKBB/oaWSCi/QHoSwsT
zZkAoKtKg2M0yvY76tw5289zDqakwwP/
=SCfx
-END PGP SIGNATURE-




Re: cp and mv commands (copying/moving only if file does not exist, regardless of the time stamps, for use in a automatic script)

2008-03-27 Thread Bob Proulx
Darren DeHaven wrote:
> I need the deprecated mv and cp command parameter "--reply=" to stay.

The problem is that it never worked as desired.

> I've noticed that the parameter "--reply=no" is "deprecated"
> 
> " cp: the --reply option is deprecated; use -i or -f instead "

Yes.  See this reference for more information.

  
http://www.gnu.org/software/coreutils/faq/#cp-and-mv-the-reply-option-is-deprecated

The problem is that --reply=no only had an affect when the command
would normally have prompted.  In particular it had no effect when the
command would *not* have prompted.  This could lead to silent data
loss.  Silent data loss is very, very bad.  See this message for
examples:

  http://lists.gnu.org/archive/html/bug-coreutils/2005-06/msg00172.html

> My issue: In a script without user input, I want to copy a file to a 
> directory if only the file doesn't already exist, (I don't want to 
> overwrite anything), and regardless of the time stamp.
> 
> The only way I see to do this is with the deprecated parameter:
> "-i --reply=no"

The solution is to use rsync instead.

  $ rsync --ignore-existing foo bar

> Example:
> "cp -i --reply=no foo bar"
> 
> This way if bar exist, then foo won't overwrite it.

That is incorrect.  It will overwrite the file if the input is
redirected such as when run from cron or when the input is redirected
by the user.  If the input is not a tty then the command would not
normally prompt.  When the command does not prompt the reply is not
used.  In that case the target is overwritten.

> This message (including attachments) contains information which is 
> confidential and privileged.

Please see:

http://goldmark.org/jeff/stupid-disclaimers/

Bob




Re: shorthand attempt at 'basename file .ext'

2008-03-27 Thread Chris F.A. Johnson
On 2008-03-25, Linda Walsh wrote:
> hey folks, have what is maybe, mostly a mental exercise, but...

> just thought that I might find some programs benefiting by not calling
> the external /[usr]/bin/{basename,filename} progs...

   You can find a shell function to replace the external basename
   command at: .

-- 
   Chris F.A. Johnson, webmaster 
   ===
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
.