How to use wget with `&` from ruby -



How to use wget with `&` from ruby -

i'm trying web page info http://example.com/foo.php?arg1=1&arg2=2.

i can page using wget without problem, when phone call wget ruby script like:

`wget http://example.com/foo.php?arg1=1&arg2=2`

then wget connect http://example.com/foo.php?arg1=1. in short wget ignores sec argument.

i tried system method, ends same error. how can utilize & wget ruby?

surround url quote prevent shell interpreter &:

`wget 'http://example.com/foo.php?arg1=1&arg2=2'` # ^ ^

or escape &:

`wget http://example.com/foo.php?arg1=1\\&arg2=2` # ^^^

update or can utilize shellwords::shellescape Зелёный suggested:

"foo&bar".shellescape # => "foo\\&bar" require 'shellwords' `wget #{shellwords.shellescape('http://example.com/foo.php?arg1=1&arg2=2')}`

or, utilize io::popen (or open3::*) not require escape:

io.popen(['wget', 'http://example.com/foo.php?arg1=1&arg2=2']).read

ruby wget

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -