shortcut to execute command in cygwin bash

Posted on 2011-04-25
Last Modified: 2013-11-15
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?
Question by:NewtonianB
    LVL 38

    Expert Comment

    Assume that your cygwin is installed at c:\cygwin\

    1. In cygwin , create and shell script called with the following content
    ---- /home/<your login name>/  ----
    /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>/

    3. The double click on backup.bat. Or you can create a shortcut for backup.bat.

    Author Comment

    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/
    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 . . .
    LVL 38

    Expert Comment

    where is your myprofile -batch file in cygwin?

    ---- /home/<your login name>/  ----
    #!/bin/sh -x
    /full-path-to-unison  /full-path-to-myprofile -batch

    Author Comment

    It's in
    LVL 38

    Expert Comment

    The path within cygwin, not Windows
    Is it  /home/NEWTON/.unsion/myprofile ?
    The modify the with the full path to myprofile

    Author Comment

    yes that's the path, I tried that unfortunately same problem umm
    LVL 38

    Accepted Solution

    1.  Within cygwin
    $ cp  /home/NEWTON/.unsion/myprofile  /cygdrive/c/Users/NEWTON/Desktop/syncprofile

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

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

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now