Douglas Muth on 11 Jun 2013 10:47:54 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] wget options to retrieve file from github



It looks like that zipfile name is sent in the Location: header of the response.  Check this out:

$ curl -I https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master 2>/dev/null |grep Location:
Location: https://codeload.github.com/mehrpadin/Superfish-for-Drupal/legacy.zip/master


If that zipfile name is in the same location in every response (is it?), you could grab it like this:

$ curl -I https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master 2>/dev/null |grep Location: |cut -d/ -f6
legacy.zip


Putting it all together:

wget -O `curl -I https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master 2>/dev/null |grep Location: |cut -d/ -f6` https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master


-- Doug

-- 
Douglas T. Muth * Philadelphia, PA, USA
http://www.dmuth.org/



On Tue, Jun 11, 2013 at 1:27 PM, Eric at Lucii.org <eric@lucii.org> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Does anyone know if there is a way to use wget to download a file and
have it use the actual file name instead of the part after the last
slash?  For example, this URL:

  https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master

I know that I can use -O filename.zip to rename the download file
but I have no idea what the file should be named (other than maybe
"superfish".)  I can guess it's a zip file from the URL element
"zipball".

When I do this:

  wget --spider https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master

Spider mode enabled. Check if remote file exists.
- --2013-06-11 10:36:22--  https://github.com/mehrpadin/Superfish-for-Drupal/zipball/master
Resolving github.com... 204.232.175.90
Connecting to github.com|204.232.175.90|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/mehrpadin/Superfish-for-Drupal/legacy.zip/master [following]
Spider mode enabled. Check if remote file exists.
- --2013-06-11 10:36:22--  https://codeload.github.com/mehrpadin/Superfish-for-Drupal/legacy.zip/master
Resolving codeload.github.com... 204.232.175.86
Connecting to codeload.github.com|204.232.175.86|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 55979 (55K) [application/zip]
Remote file exists.

...I see that there is a sort-of actual filename in the URL: legacy.zip


Any hints/tips/tricks/cheat codes/insights would be appreciated,

Oops, stumbled upon this:

  https://addons.mozilla.org/en-US/firefox/addon/cliget/

Very clever program - I think I'll use it even if I have to switch back
to FireFox sometimes.

Eric
- --
#  Eric Lucas
#
#                "Oh, I have slipped the surly bond of earth
#                 And danced the skies on laughter-silvered wings...
#                                        -- John Gillespie Magee Jr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlG3Xg0ACgkQ2sGpvXQrZ/5zWwCeNChxzpc7VQwutHmIQKpNhZRp
QkwAniTlgvzkrZnAsMk/pRG8RySz5tUE
=6HLF
-----END PGP SIGNATURE-----
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug





___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug