1

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.

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Sitak
  • 153
  • 8
  • 1
    I guess output went to errorstream, to merge with normal output append `2>&1` –  Sep 03 '17 at 17:27
  • Non-admin users aren't allowed to create files in the root directory of the system drive. You wouldn't need admin access if you created the file in a subdirectory such as "C:\Temp". – Eryk Sun Sep 04 '17 at 02:21
  • @LotPings, it's working! But then I don't have any output on the cmd. Is it possible to have both (the print in the cmd and the print in the output file). Also please mark you comment in an answer, so I get accept it. – Sitak Sep 04 '17 at 12:33

2 Answers2

1

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"
0

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

  • Thanks! This did remove the "Access is denied" and allows the script to run but the output file is empty, even thought I get a lot of print on cmd – Sitak Sep 03 '17 at 17:15