Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output Cygwin/bash results to text file

I'm writing a script that will run from the Task Scheduler. It's not executing correctly from the Scheduler, but will execute correctly from the command line. (Possibly a permissions issue?) I wanted to redirect the output to a text file, but I'm getting an empty results.txt file when executed from either the command line or the Scheduler.

This is the content of the batch file:

D:
chdir D:\scripts
C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt
like image 935
Michael Gorham Avatar asked Nov 16 '11 19:11

Michael Gorham


1 Answers

Maybe your script writes to the standard error (stderr). Try changing

C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt

to

C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt  2>&1

It's redirects stderr too to the file.

like image 184
palacsint Avatar answered Sep 30 '22 12:09

palacsint