Issue
I do have a PowerShell script which is working fine - it downloads a Google-Spreadsheet and saves it as target.csv:
curl https://some-url.com -O target.csv
When I try to do this via batch script:
start powershell curl https://some-url.com -O target.csv
it doesn't save the file. I´ve tried it also with >> target.csv
and I get the file with no content.
It should run on a Windows 2008 Server with PowerShell 1 and installed curl.exe
Edit: My actual bat File:
start powershell -noexit curl https://docs.google.com/spreadsheets/d/e/2PACX-1vSV966X52f-JvdpwnJbFGeHFlG7uR48069MtD4tvPRintmqH_O2JEclIg6knXkKUuO-dGEhS69LdM1P/pub?gid=556715578&single=true&output=csv -O target.csv
When I'm using ""
at the URL I´m getting the following Error:
In Zeile:1 Zeichen:151
+ ... tvPRintmqH_O2JEclIg6knXkKUuO-dGEhS69LdM1P/pub?gid=556715578&&single=t ...
+ ~~
Das Token "&&" ist in dieser Version kein gültiges Anweisungstrennzeichen.
In Zeile:1 Zeichen:164
+ ... JEclIg6knXkKUuO-dGEhS69LdM1P/pub?gid=556715578&&single=true&&output=c ...
+ ~~
Das Token "&&" ist in dieser Version kein gültiges Anweisungstrennzeichen.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine
Without the ""
the download starts but it downloads not the desired data:
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html><html><head><title>Kleine Zeitung Paid Content</title><meta name="viewport" content=
"target-densitydpi=device-dpi,user-scalable=1,minimum-scale=1,maximum-scale=2.5,initial-scale=1,wid
th...
RawContent : HTTP/1.1 200 OK
X-Robots-Tag: noindex, nofollow, nosnippet
Cache-Control: private, max-age=300
Content-Type: text/html; charset=utf-8
Date: Thu, 07 Mar 2019 12:36:20 GMT
Expires: Thu, 07 Mar 2019...
Forms : {}
Headers : {[X-Robots-Tag, noindex, nofollow, nosnippet], [Cache-Control, private, max-age=300],
[Content-Type, text/html; charset=utf-8], [Date, Thu, 07 Mar 2019 12:36:20 GMT]...}
Images : {}
InputFields : {}
Links : {@{innerHTML=Google Sheets; innerText=Google Sheets; outerHTML=<A title="Learn more about Google
Sheets" href="https://docs.google.com/spreadsheets/?usp=sheets_web" target=_blank>Google
Sheets</A>; outerText=Google Sheets; tagName=A; title=Learn more about Google Sheets;
href=https://docs.google.com/spreadsheets/?usp=sheets_web; target=_blank}, @{innerHTML=Missbrauch
melden; innerText=Missbrauch melden; outerHTML=<A href="https://docs.google.com/abuse?id=e/2PACX-1v
SV966X52f-JvdpwnJbFGeHFlG7uR48069MtD4tvPRintmqH_O2JEclIg6knXkKUuO-dGEhS69LdM1P">Missbrauch
melden</A>; outerText=Missbrauch melden; tagName=A; href=https://docs.google.com/abuse?id=e/2PACX-1
vSV966X52f-JvdpwnJbFGeHFlG7uR48069MtD4tvPRintmqH_O2JEclIg6knXkKUuO-dGEhS69LdM1P}}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 2179532
Edit2
We figured out that the &
is the Problem, so I've tried many variations, %26
\&
&
'&'
"&"
but none of them worked properly.
When I'm starting it manually via PowerShell it's working, as a bat it isn't - mostly the same Error (Error 1).
So I need to find a way to use the &
in a batch file.
Edit3
Finally solved
"https://docs.google.com/spreadsheets/d/e/2PACX-1vSV966X52f-JvdpwnJbFGeHFlG7uR48069MtD4tvPRintmqH_O2JEclIg6knXkKUuO-dGEhS69LdM1P/pub?gid=556715578'&'single=true'&'output=csv"
As you see the Problem/Solution has been the double quotes and the single quotes Thank You!
Solution
Thank You @Compo!
I also got always a target.csv, either an empty one or it has the 'wrong' data.
It was a problem with the &
and finally we solved it:
"http://....'&'....'&'...."
Thank You
Answered By - Tom tom Answer Checked By - Senaida (WPSolving Volunteer)