Output Cygwin/bash results to text file
Asked Answered
T

3

7

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
Tyrothricin answered 16/11, 2011 at 19:53 Comment(1)
there is 'select all' option with cygwin. just copy paste itUnreserved
P
12

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.

Protostele answered 17/11, 2011 at 12:30 Comment(0)
P
0

Try a UNIX style file path:

C:\cygwin\bin\bash --login -i /cygdrive/d/scripts/myscript.sh > results.txt
Pepsinogen answered 17/11, 2011 at 13:7 Comment(0)
P
0

Open cygwin.bat run as admin First goto log path then run below commands

cd C:/cygwin64/var/log

cp [log_file_name] [result_file_name.txt]

Note :- not to include square braces.

Predominance answered 24/7 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.