# Issue with Cygwin ssh rsync from Unix sh script on Windows 7 64 bit



## govango (Feb 14, 2013)

I have cygwin installed on both a Win 7 32 bit machine and on Win 7 64 bit machine. The setup on Win 7 32 is working. I am having trouble with the setup on Win 7 64. 

I am trying to automate cygwin rsync by calling a unix shell script in the /cygdrive/c/cygwin/usr/local/bin.

I have ssh installed as local service and privledged separation and start it using hstart as I want to run with highest privileges so do not have to see the console windows. Our application is calling a datasync.sh script by writing to the dos command prompt. This works fine on Win 7 32 bit machine.

On the Win 7 64 bit machine, the same process does not work. Although I can ssh without password through the cygwin terminal without error and call the same rsync commands as in the script manually without error.

This is the cygcheck:

$ cygcheck -s

Cygwin Configuration Diagnostics
Current System Time: Thu Feb 14 15:23:44 2013

Windows 7 Professional N Ver 6.1 Build 7601 Service Pack 1

Running under WOW64 on AMD64

Path: C:\cygwin\usr\local\bin
C:\cygwin\bin
C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live
C:\Program Files (x86)\Intel\iCLS Client
C:\Program Files\Intel\iCLS Client
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0
C:\Program Files (x86)\Windows Live\Shared
C:\Program Files\Trend Micro\AMSP
C:\Executables
C:\cygwin

Output from C:\cygwin\bin\id.exe
UID: 1000(Jance) GID: 513(None)
513(None) 544(Administrators) 545(Users)

SysDir: C:\Windows\system32
WinDir: C:\Windows

USER = 'Jance'
PWD = '/home/Jance'
HOME = '/home/Jance'

Use '-r' to scan registry

obcaseinsensitive set to 1

Cygwin installations found in the registry:
System: Key: c5e39b7a9d22bafb Path: C:\cygwin
User: Key: c5e39b7a9d22bafb Path: C:\cygwin

c: hd NTFS 934813Mb 5% CP CS UN PA FC OS
d: cd N/A N/A
e: fd N/A N/A

C:\cygwin / system binary,auto
C:\cygwin\bin /usr/bin system binary,auto
C:\cygwin\lib /usr/lib system binary,auto
cygdrive prefix /cygdrive user binary,auto

Found: C:\cygwin\bin\awk
-> C:\cygwin\bin\gawk.exe
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cp.exe
Not Found: cpp (good!)
Found: C:\cygwin\bin\crontab.exe
Found: C:\cygwin\bin\find.exe
Found: C:\Windows\system32\find.exe
Not Found: gcc
Not Found: gdb
Found: C:\cygwin\bin\grep.exe
Found: C:\cygwin\bin\kill.exe
Not Found: ld
Found: C:\cygwin\bin\ls.exe
Not Found: make
Found: C:\cygwin\bin\mv.exe
Not Found: patch
Not Found: perl
Found: C:\cygwin\bin\rm.exe
Found: C:\cygwin\bin\sed.exe
Found: C:\cygwin\bin\ssh.exe
Found: C:\cygwin\bin\sh.exe
Found: C:\cygwin\bin\tar.exe
Found: C:\cygwin\bin\test.exe
Not Found: vi
Not Found: vim

449k 2013/01/01 C:\cygwin\bin\cygasn1-8.dll
14k 2012/05/04 C:\cygwin\bin\cygattr-1.dll
62k 2011/05/21 C:\cygwin\bin\cygbz2-1.dll
10k 2012/11/04 C:\cygwin\bin\cygcom_err-2.dll
7k 2012/05/07 C:\cygwin\bin\cygcrypt-0.dll
1516k 2012/09/01 C:\cygwin\bin\cygcrypto-1.0.0.dll
373k 2013/02/08 C:\cygwin\bin\cygcurl-4.dll
140k 2012/05/03 C:\cygwin\bin\cygedit-0.dll
148k 2012/06/08 C:\cygwin\bin\cygexpat-1.dll
43k 2010/01/02 C:\cygwin\bin\cygform-10.dll
47k 2010/01/02 C:\cygwin\bin\cygformw-10.dll
79k 2011/10/26 C:\cygwin\bin\cyggcc_s-1.dll
317k 2011/07/31 C:\cygwin\bin\cyggmp-3.dll
180k 2013/01/01 C:\cygwin\bin\cyggssapi-3.dll
11k 2013/01/01 C:\cygwin\bin\cygheimbase-1.dll
20k 2013/01/01 C:\cygwin\bin\cygheimntlm-0.dll
25k 2012/05/04 C:\cygwin\bin\cyghistory7.dll
211k 2013/01/01 C:\cygwin\bin\cyghx509-5.dll
358k 2012/04/14 C:\cygwin\bin\cygicons-0.dll
985k 2011/10/16 C:\cygwin\bin\cygiconv-2.dll
192k 2012/08/30 C:\cygwin\bin\cygidn-11.dll
35k 2011/10/16 C:\cygwin\bin\cygintl-8.dll
21k 2013/01/01 C:\cygwin\bin\cygkafs-0.dll
373k 2013/01/01 C:\cygwin\bin\cygkrb5-26.dll
40k 2012/11/26 C:\cygwin\bin\cyglber-2-4-2.dll
230k 2012/11/26 C:\cygwin\bin\cygldap-2-4-2.dll
244k 2012/11/26 C:\cygwin\bin\cygldap_r-2-4-2.dll
6k 2012/10/19 C:\cygwin\bin\cyglsa.dll
9k 2012/10/19 C:\cygwin\bin\cyglsa64.dll
123k 2011/05/19 C:\cygwin\bin\cyglzma-5.dll
94k 2012/04/22 C:\cygwin\bin\cygmagic-1.dll
25k 2010/01/02 C:\cygwin\bin\cygmenu-10.dll
25k 2010/01/02 C:\cygwin\bin\cygmenuw-10.dll
35k 2012/11/22 C:\cygwin\bin\cygmetalink-3.dll
213k 2011/07/31 C:\cygwin\bin\cygmp-3.dll
63k 2010/01/02 C:\cygwin\bin\cygncurses++-10.dll
63k 2010/01/02 C:\cygwin\bin\cygncurses++w-10.dll
195k 2010/01/02 C:\cygwin\bin\cygncurses-10.dll
244k 2010/01/02 C:\cygwin\bin\cygncursesw-10.dll
13k 2010/01/02 C:\cygwin\bin\cygpanel-10.dll
13k 2010/01/02 C:\cygwin\bin\cygpanelw-10.dll
255k 2012/02/10 C:\cygwin\bin\cygpcre-0.dll
22k 2002/06/09 C:\cygwin\bin\cygpopt-0.dll
162k 2012/05/04 C:\cygwin\bin\cygreadline7.dll
51k 2013/01/01 C:\cygwin\bin\cygroken-18.dll
566k 2012/08/08 C:\cygwin\bin\cygsqlite3-0.dll
131k 2012/05/21 C:\cygwin\bin\cygssh2-1.dll
359k 2012/09/01 C:\cygwin\bin\cygssl-1.0.0.dll
8k 2011/10/26 C:\cygwin\bin\cygssp-0.dll
780k 2011/10/26 C:\cygwin\bin\cygstdc++-6.dll
48k 2010/01/02 C:\cygwin\bin\cygtic-10.dll
48k 2010/01/02 C:\cygwin\bin\cygticw-10.dll
157k 2013/01/01 C:\cygwin\bin\cygwind-0.dll
28k 2010/03/28 C:\cygwin\bin\cygwrap-0.dll
71k 2012/05/13 C:\cygwin\bin\cygz.dll
2791k 2012/10/19 C:\cygwin\bin\cygwin1.dll
Cygwin DLL version info:
DLL version: 1.7.17
DLL epoch: 19
DLL old termios: 5
DLL malloc env: 28
Cygwin conv: 181
API major: 0
API minor: 262
Shared data: 5
DLL identifier: cygwin1
Mount registry: 3
Cygwin registry name: Cygwin
Program options name: Program Options
Installations name: Installations
Cygdrive default prefix:
Build date:
Shared id: cygwin1S5


No Cygwin services found.


Cygwin Package Information
Package Version Status
_autorebase 000207-1 OK
_update-info-dir 01104-1 OK
alternatives 1.3.30c-10 OK
autossh 1.4c-1 OK
base-cygwin 3.1-1 OK
base-files 4.1-1 OK
bash 4.1.10-4 OK
bzip2 1.0.6-2 OK
coreutils 8.15-1 OK
cron 4.1-59 OK
crypt 1.2-1 OK
csih 0.9.6-1 OK
curl 7.29.0-1 OK
cygrunsrv 1.40-2 OK
cygutils 1.4.10-2 OK
cygwin 1.7.17-1 OK
cygwin-doc 1.7-1 OK
dash 0.5.7-1 OK
diffutils 3.2-1 OK
dos2unix 6.0.3-1 OK
editrights 1.01-2 OK
file 5.11-1 OK
findutils 4.5.9-2 OK
gawk 4.0.2-1 OK
gettext 0.18.1.1-2 OK
grep 2.6.3-1 OK
groff 1.21-2 OK
gzip 1.4-1 OK
ipc-utils 1.0-1 OK
less 444-1 OK
libasn1_8 1.5.2-4 OK
libattr1 2.4.46-1 OK
libbz2_1 1.0.6-2 OK
libcom_err2 1.42.6-1 OK
libcurl4 7.29.0-1 OK
libedit0 20120311-1 OK
libexpat1 2.1.0-1 OK
libgcc1 4.5.3-3 OK
libgmp3 4.3.2-1 OK
libgssapi3 1.5.2-4 OK
libheimbase1 1.5.2-4 OK
libheimntlm0 1.5.2-4 OK
libhx509_5 1.5.2-4 OK
libiconv2 1.14-2 OK
libidn11 1.25-1 OK
libintl8 0.18.1.1-2 OK
libkafs0 1.5.2-4 OK
libkrb5_26 1.5.2-4 OK
liblzma5 5.0.2_20110517-1 OK
libmetalink3 0.1.2-1 OK
libncurses10 5.7-18 OK
libncursesw10 5.7-18 OK
libopenldap2_4_2 2.4.33-1 OK
libopenssl100 1.0.1c-2 OK
libpcre0 8.21-2 OK
libpopt0 1.6.4-4 OK
libreadline7 6.1.2-3 OK
libroken18 1.5.2-4 OK
libsqlite3_0 3.7.13-1 OK
libssh2_1 1.4.2-1 OK
libssp0 4.5.3-3 OK
libstdc++6 4.5.3-3 OK
libwind0 1.5.2-4 OK
libwrap0 7.6-21 OK
login 1.10-10 OK
man 1.6g-1 OK
mintty 1.1.2-1 OK
nano 2.2.6-1 OK
openssh 6.1p1-1 OK
rebase 4.4.0-1 OK
rsync 3.0.9-1 OK
run 1.1.13-1 OK
sed 4.2.1-2 OK
tar 1.26-1 OK
terminfo 5.7_20091114-14 OK
texinfo 4.13-4 OK
tzcode 2012j-1 OK
unison2.45 2.45.28-1 OK
which 2.20-2 OK
xinetd 2.3.14-1  OK
xz 5.0.2_20110517-1 OK
zlib0 1.2.7-1 OK
Use -h to see help about each section


Here is a copy of the unix datasync.sh script: 


#!/bin/bash

# begin script file


#!/bin/bash

#

# script for rsync back up of

# C:/ProgramData/companyname/Images

# C:/ProgramData/companyname/Documents

# to/from companyname Linux cloud server

# and creation of rsysnc log

# $1 = [email protected]:username/Images/

# $2 = /cygdrive/c/ProgramData/companyname/Images/

# $3 = [email protected]:username/Documents/

# $4 = /cygdrive/c/ProgramData/companyname/Documents/


echo "starting"


echo " " >> /cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt

echo " " >> /cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt

echo "***** new log entry *****" >> /cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt

date >>/cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt


rsync -avz -t --exclude=".DS_Store" --no-owner --no-group --no-perms --chmod=ugo=rwx -e ssh --log-file=/cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt $1 $2

rsync -avz -t --exclude=".DS_Store" --no-owner --no-group --no-perms --chmod=ugo=rwx -e ssh --log-file=/cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt $2 $1

rsync -avz -t --exclude=".DS_Store" --no-owner --no-group --no-perms --chmod=ugo=rwx -e ssh --log-file=/cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt $3 $4

rsync -avz -t --exclude=".DS_Store" --no-owner --no-group --no-perms --chmod=ugo=rwx -e ssh --log-file=/cygdrive/c/ProgramData/companyname/_rsync_logs/Data_Files_log.txt $4 $3


echo done

The rsync-logs/Data_files_logs.txt get created but rsync returns this error: 

rsync error: syntax or usage error (code 1) at /home/lapo/package/rsync-3.0.9-1/src/rsync-3.0.9/main.c(1503) [Receiver=3.0.9]
2013/02/12 11:45:21 [6208] rsync version 3.0.9 protocol version 30

Thanks in advance for any assistance.


----------

