• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1122
  • Last Modified:

shortcut to execute command in cygwin bash

I have a command
unison myprofile -batch
which works fine in cygwin bash shell. It uses ssh, unison and probably rsync to work.
How can I make a windows shortcut that can execute this command?
  • 4
  • 3
1 Solution
Assume that your cygwin is installed at c:\cygwin\

1. In cygwin , create and shell script called backup.sh with the following content
---- /home/<your login name>/backup.sh  ----
/full-path-to-unison myprofile -batch

2. Open the notepad, create a batch file on desktop with this content
---- backup.bat -----
c:\cygwin\bin\sh.exe  /home/<your login name>/backup.sh

3. The double click on backup.bat. Or you can create a shortcut for backup.bat.
NewtonianBAuthor Commented:
Thanks wesly I have a problem though something is screwy seems to be happening with unison when ran from this bat script. Some paths are different.

All that syncprofile has is
root = /cygdrive/c/myfolder/
root = ssh://user@server//cygdrive/c/myfolder/

Through the bat script instead of getting

unison syncprofile -batch
Contacting server..
Connected //MYSERVER//cygdrive/c/myfolder -> //LOCAL//cygdrive/c/myfolder
Looking for changes
      Waiting for changes
      Reconciling changes
I get      

C:\Users\NEWTON\Desktop>c:\cygwin\bin\sh.exe  /home/NEWTON/backupscript.sh
Contacting server...
Looking for changes
Warning: No archive files were found for these roots, whose canonical names are:

This can happen either
because this is the first time you have synchronized these roots,
or because you have upgraded Unison to a new version with a different
archive format.

Update detection may take a while on this run if the replicas are

Unison will assume that the 'last synchronized state' of both replicas
was completely empty.  This means that any files that are different
will be reported as conflicts, and any files that exist only on one
replica will be judged as new and propagated to the other replica.
If the two replicas are identical, then no changes will be reported.

If you see this message repeatedly, it may be because one of your machines
is getting its address from DHCP, which is causing its host name to change
between synchronizations.  See the documentation for the UNISONLOCALHOSTNAME
environment variable for advice on how to correct this.

Donations to the Unison project are gratefully accepted:

Reconciling changes
Nothing to do: replicas have not changed since last sync.

Press any key to continue . . .
where is your myprofile -batch file in cygwin?

---- /home/<your login name>/backup.sh  ----
#!/bin/sh -x
/full-path-to-unison  /full-path-to-myprofile -batch
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

NewtonianBAuthor Commented:
It's in
The path within cygwin, not Windows
Is it  /home/NEWTON/.unsion/myprofile ?
The modify the backup.sh with the full path to myprofile
NewtonianBAuthor Commented:
yes that's the path, I tried that unfortunately same problem umm
1.  Within cygwin
$ cp  /home/NEWTON/.unsion/myprofile  /cygdrive/c/Users/NEWTON/Desktop/syncprofile

---- /home/<your login name>/backup.sh  ----
#!/bin/sh -x     # <== debug mode
/full-path-to-unison /cygdrive/c/Users/NEWTON/Desktop/syncprofile  -batch

---- backup.bat -----
set HOME=\Users\NEWTON
c:\cygwin\bin\bash  -c '/home/NEWTON/backup.sh'

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now