Sitak
Sitak

Reputation: 153

Empty file when output is written to a file (python gsutil run from cmd)

I use gsutil for uploading a file to Google cloud storage. I would like to write the output to a file.

I have created a shortcut with this command in it

%windir%\system32\cmd.exe /k python2 c:\gsutil\gsutil -m rsync -r -n -d "XX" gs://xx/XX > C:\myoutput.txt

I run the cmd as admin. The output.txt file is created but it's empty after the script exits.

Any idea how I solve this?


Old question:

I have tried adding /myoutput.txt cf here after gs://xx/XX it doesn't works : I get a Access is denied. message.

Upvotes: 1

Views: 424

Answers (2)

user6811411
user6811411

Reputation:

I guess output went to errorstream, to merge with normal output append 2>&1

To redirect to a file and see on screen you need a tee or t-pipe tool.

There is one contained in GNU utilities for Win32 or one from Bill Stewart's Site

So your command could look like (untested)

%windir%\system32\cmd.exe /k python2 c:\gsutil\gsutil -m rsync -r -n -d "XX" gs://xx/XX 2>&1|tee "%USERPROFILE%\Desktop\myoutput.txt"

Upvotes: 1

Sleepycoder
Sleepycoder

Reputation: 9

try to write to a different place or give the cmd admin, that would be my guess. Hope this helps)

Upvotes: 0

Related Questions