public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Why does robocopy confuse input and output files defined with Cygwin/bash and perl?
@ 2015-09-30 14:54 siegfried
  2015-09-30 15:07 ` Eliot Moss
  0 siblings, 1 reply; 4+ messages in thread
From: siegfried @ 2015-09-30 14:54 UTC (permalink / raw)
  To: cygwin


I sent this once and it did not appear in the list. Maybe I typed the
list name wrong? 
I apologize if this appears twice.


I think the following code below should work (unfortunately, my email
program wants to wrap the code). The results of the echo
statement look fine! When I cut and paste the results of the echo, the
robocopy command works great!

OK! Now I want to automate it and instead of just displaying the
robocopy command with echo, actually execute it! 
But why won't it execute directly?

For some reason, I get the errors below. Why is robocopy getting
confused on the input and output files?



Thanks
siegfried





src=$(perl -e '$u = $ENV{"USERNAME"};$s = $_ = $ARGV[0]; $_ =
lcfirst;s@[/\\]@\\\\@g; s@\s@\\ @g; s/(.):/$1\\:/; print " $_";
'"$(cygpath -w $PWD)")
dst=$(perl -e '$u = $ENV{"USERNAME"}; $_ = $ARGV[0]; $_ = lcfirst;
s@(/cygdrive/c|c:)[/\\]+Users[/\\]+$u([/\\]+Documents([/\\]+)?)?@f:\\backup\\unison\\@g;s@(c:\\cygwin(64)?)?[\\/]+home[\\/]+$u([\\/]+)?@f:\\backup\\unison\\HOME\\@g;s@[/\\]@\\\\@g;
s@\s@\\ @g; s/(.):/$1\\:/; print " $_"; $p="";foreach (split "[/\\\\]"){
$p = $p.$_."/"; mkdir $p unless -e $p } ' "$(cygpath -w $PWD)")
echo src=$src
echo dst=$dst
echo robocopy /s $src $dst
robocopy $src $dst

--- output from above commands:

src= c\:\\Users\\siegfried\\Documents\\bin
dst= f\:\\backup\\unison\\bin
robocopy /s c\:\\Users\\siegfried\\Documents\\bin
f\:\\backup\\unison\\bin

-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows 

-------------------------------------------------------------------------------

Started : Tuesday, September 29, 2015 7:53:04 PM
Source :
c:\Users\siegfried\Documents\bin\c\:\Users\siegfried\Documents\bin\
Dest : c:\Users\siegfried\Documents\bin\f\:\backup\unison\bin\

Files : *.*

Options : *.* /DCOPY:DA /COPY:DAT /R:1000000 /W:30 

------------------------------------------------------------------------------

2015/09/29 19:53:04 ERROR 123 (0x0000007B) Accessing Source Directory
c:\Users\siegfried\Documents\bin\c\:\Users\siegfried\Documents\bin\
The filename, directory name, or volume label syntax is incorrect.

Compilation exited abnormally with code 16 at Tue Sep 29 19:53:04

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why does robocopy confuse input and output files defined with Cygwin/bash and perl?
  2015-09-30 14:54 Why does robocopy confuse input and output files defined with Cygwin/bash and perl? siegfried
@ 2015-09-30 15:07 ` Eliot Moss
  2015-09-30 19:35   ` Andrey Repin
  0 siblings, 1 reply; 4+ messages in thread
From: Eliot Moss @ 2015-09-30 15:07 UTC (permalink / raw)
  To: siegfried; +Cc: cygwin

Dealing with "odd" characters like \ and such can be a pain, huh?
Perhaps it will help you to know that bash will expand variables
inside double-quoted arguments, i.e., "${src}".  (You can write
"$src" if you want, but over the years I am finding it clearer /
better to use the { } to make clear the name of the variable I
want expanded.)

Also, you may find the cygpath utility helpful, and the $( ) idiom
of bash.  Thus:

robocopy /s "$(cygpath -w /cygdrive/c/Users/siegfriend/Documents/bin)" "$(cygpath -w 
/cygdrive/f/backup/unison/bin)"

I believe this will do what you want.  cygpath can be very helpful
hen you desire to run a Windows program from the cygwin environment.

Regards -- Eliot Moss

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why does robocopy confuse input and output files defined with Cygwin/bash and perl?
  2015-09-30 15:07 ` Eliot Moss
@ 2015-09-30 19:35   ` Andrey Repin
  2015-10-01 13:13     ` cyg Simple
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Repin @ 2015-09-30 19:35 UTC (permalink / raw)
  To: Eliot Moss, cygwin

Greetings, Eliot Moss!

> Dealing with "odd" characters like \ and such can be a pain, huh?
> Perhaps it will help you to know that bash will expand variables
> inside double-quoted arguments, i.e., "${src}".  (You can write
> "$src" if you want, but over the years I am finding it clearer /
> better to use the { } to make clear the name of the variable I
> want expanded.)

> Also, you may find the cygpath utility helpful, and the $( ) idiom
> of bash.

It isn't "idiom of bash", it is a POSIX construction.

> Thus:

> robocopy /s "$(cygpath -w /cygdrive/c/Users/siegfriend/Documents/bin)" "$(cygpath -w
> /cygdrive/f/backup/unison/bin)"

> I believe this will do what you want.  cygpath can be very helpful
> hen you desire to run a Windows program from the cygwin environment.

I would suggest cygpath -m.


-- 
With best regards,
Andrey Repin
Wednesday, September 30, 2015 22:26:55

Sorry for my terrible english...


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why does robocopy confuse input and output files defined with Cygwin/bash and perl?
  2015-09-30 19:35   ` Andrey Repin
@ 2015-10-01 13:13     ` cyg Simple
  0 siblings, 0 replies; 4+ messages in thread
From: cyg Simple @ 2015-10-01 13:13 UTC (permalink / raw)
  To: cygwin

On 9/30/2015 3:27 PM, Andrey Repin wrote:
> Greetings, Eliot Moss!
> 
>> Dealing with "odd" characters like \ and such can be a pain, huh?
>> Perhaps it will help you to know that bash will expand variables
>> inside double-quoted arguments, i.e., "${src}".  (You can write
>> "$src" if you want, but over the years I am finding it clearer /
>> better to use the { } to make clear the name of the variable I
>> want expanded.)
> 
>> Also, you may find the cygpath utility helpful, and the $( ) idiom
>> of bash.
> 
> It isn't "idiom of bash", it is a POSIX construction.
> 
>> Thus:
> 
>> robocopy /s "$(cygpath -w /cygdrive/c/Users/siegfriend/Documents/bin)" "$(cygpath -w
>> /cygdrive/f/backup/unison/bin)"
> 
>> I believe this will do what you want.  cygpath can be very helpful
>> hen you desire to run a Windows program from the cygwin environment.
> 
> I would suggest cygpath -m.

Not for robocopy, it is likely not to survive / instead of \.  I would
prefix it with "cmd /c" though or perhaps create a bash script called
robocopy to do the path conversion before calling the Windows
robocopy.exe.  That way the command line looks typical.

-- 
cyg Simple

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-01 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30 14:54 Why does robocopy confuse input and output files defined with Cygwin/bash and perl? siegfried
2015-09-30 15:07 ` Eliot Moss
2015-09-30 19:35   ` Andrey Repin
2015-10-01 13:13     ` cyg Simple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).