Subject: | |
From: | |
Reply To: | |
Date: | Tue, 29 Jul 2014 13:36:30 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On 07/29/2014 01:18 PM, David Sommerseth wrote:
> On 29/07/14 20:37, ToddAndMargo wrote:
>> On 07/29/2014 10:40 AM, David Sommerseth wrote:
>>> On 29/07/14 19:04, ToddAndMargo wrote:
>>>> Hi All,
>>>>
>>>> I am trying to extract the file name (for the revision)
>>>> of a file with "--content-disposition". I don't actually
>>>> want the file.
>>>>
>>>> Is there a way to have wget tell me the name of the file
>>>> without actually downloading it?
>>>>
>>>> Many thanks,
>>>> -T
>>>>
>>>> This is what I have so far. Tell me the file exists
>>>> but not its name.
>>>>
>>>>
>>>> wget --spider --content-disposition
>>>> "http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm"
>>>>
>>>> Spider mode enabled. Check if remote file exists.
>>>> --2014-07-29 10:00:38--
>>>> http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm
>>>>
>>>> Resolving www.overlooksoft.com... 96.127.149.74
>>>> Connecting to www.overlooksoft.com|96.127.149.74|:80... connected.
>>>> HTTP request sent, awaiting response... 200 OK
>>>> Length: 6737765 (6.4M) [application/x-rpm]
>>>>
>>>> Remote file exists.
>>>
>>> $ curl -I
>>> 'http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm' \
>>> | awk -F= '/Content-Disposition: attachment;/ {print $2}'
>>>
>>> Not sure if wget got a similar feature. I just happen to like curl
>>> slightly better.
>>>
>>>
>>> --
>>> kind regards,
>>>
>>> David Sommerseth
>>>
>>
>> Hi David,
>>
>> I must be missing something. Don't see the name anywhere.
>>
>> And, can't figure out why I get something different with
>> the AWK pipe.
>>
>> -T
>>
>> $ curl -I 'http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm'
>> HTTP/1.1 403 Forbidden
>> Date: Tue, 29 Jul 2014 18:34:31 GMT
>> Server: Apache
>> Content-Type: text/html; charset=iso-8859-1
>>
>> $ curl -I
>> 'http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm' |
>> awk -F= '/Content-Disposition: attachment;/ {print $2}'
>> % Total % Received % Xferd Average Speed Time Time Time
>> Current
>> Dload Upload Total Spent Left
>> Speed
>> 0 0 0 0 0 0 0 0 --:--:-- --:--:--
>> --:--:-- 0
>
> Odd! You get "403 Forbidden". I don't get that from my Fedora 19 box:
>
> $ curl -I 'http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm'
> HTTP/1.1 200 OK
> Date: Tue, 29 Jul 2014 20:14:31 GMT
> Server: Apache
> X-Powered-By: PHP/5.4.28
> Pragma: public
> Expires: 0
> Cache-Control: public
> Content-Description: File Transfer
> Content-Disposition: attachment; filename="overlook-fing-2.2.rpm"
> Content-Transfer-Encoding: binary
> Content-Length: 6737765
> Vary: User-Agent
> Content-Type: application/x-rpm
>
> However on a SL6.5 box, I do get "403 Forbidden".
>
> I tried changing the User-Agent string, and that helped. Seems some
> curl versions have been banned on that site.
>
> Pick a user-agent string from here:
> <http://www.useragentstring.com/pages/Firefox/>
>
> And run curl with '-A $USERAGENT' ... that should fix it.
>
>
> --
> kind regards,
>
> David Sommerseth
>
Hi David,
curl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:25.0)
Gecko/20100101 Firefox/25.0" -I
'http://www.overlooksoft.com/packages/download?plat=lx64&ext=rpm' 2>&1 |
grep -i "Content-Disposition" | awk -F '"' '{print $2}'
overlook-fing-2.2.rpm
Did the trick!
Thank you for helping me with this.
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|