Search code examples
bashcygwin

cywin bash script command not found when called from batch


#!/bin/bash
echo "Testing"
cd "/cygdrive/x/Internal Communications/Riccardo/"
filename=htdocs-`date +%A`.tar.gz
tar cvzf $filename "/cygdrive/c/Program Files/Zend/Apache2/htdocs"

The above script is working when it is called inside cygwin console, but when I try to call it from a batch file I get "command not found" for date and tar command. I think that bash.exe does not have the PATH set up.

I need to run that script from that batch file because I want to add the script to the task scheduler.


Solution

  • Put your cygwin bin directory (likely C:\cygwin\bin) on your PATH environment variable.

    This would also give you the benefit of being able to use commands like tar, ls, rm, etc. from a regular console windows and not just a Cygwin console.