apri21
apri21

Reputation: 1

using wget to get excel file

I'm sorry I do not speak English very well. I want to use wget to get an excel file with a link :

 http://app/sip/rkn/export.php?p1=1&p2=613&p3=01&p4=31&p5=01&p6=2013

but I'm getting an error message :

'p2' is not recognized as an internal or external command,
operable program or batch file.
'p3' is not recognized as an internal or external command,
operable program or batch file.
'p4' is not recognized as an internal or external command,
operable program or batch file.
'p5' is not recognized as an internal or external command,
operable program or batch file.
'p6' is not recognized as an internal or external command,
operable program or batch file.

What can I do to solve this issue? Thanks in advance!

Upvotes: 0

Views: 3112

Answers (2)

Adrian Frühwirth
Adrian Frühwirth

Reputation: 45616

The problem is that the & character is interpreted by the shell, for which it has a special meaning (see here).

Try the following commands in your shell to understand what it does:

$ sleep 2 && echo "2 seconds have passed"

$ sleep 2 && echo "2 seconds have passed" &

Simplified, the syntax runs the specified command before the & in the background, which means the string that comes after the & is interpreted as a new command by the shell. Try this example to understand what happens:

$ wget foo&ls

To overcome the problem, you need to enclose your link in quotes. Double quotes ("") might not be sufficient, because a string enclosed in double quotes is subject to e.g. parameter expansion, so if your link includes something that looks like a shell variable (e.g. $FOO) your link will be mangled.

Enclose it in single quotes instead to make sure wget sees the link "as it is":

$ wget 'http://app/sip/rkn/export.php?p1=1&p2=613&p3=01&p4=31&p5=01&p6=2013'

Upvotes: 1

Francesco Casula
Francesco Casula

Reputation: 27130

Your link is broken, if it is a fake link (used in order to do an example), you can try quoting the URL like this:

wget "http://www.example.com/export.php?p1=1&p2=613&p3=01&p4=31&p5=01&p6=2013"

Upvotes: 0

Related Questions